https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104228
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu.org --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- If the testcase is extended to: program p character(:), save, allocatable :: x(:) call s1 call s2 call s3 call s4 contains subroutine s1 associate (y1 => x) y1 = [x] end associate end subroutine s2 associate (y2 => x) y2 = [x] end associate end subroutine s3 associate (y3 => x) y3 = [x] end associate end subroutine s4 associate (y4 => x) y4 = [x] end associate end end then the p program contains just one of those y vars (y4/.y4): __attribute__((fn spec (". "))) void p () { static voidD.27 s4D.4214 (void); static voidD.27 s3D.4216 (void); static voidD.27 s2D.4218 (void); static voidD.27 s1D.4220 (void); struct array01_character(kind=1) y4D.4244; static integer(kind=8)D.9 .y4D.4222; static struct array01_character(kind=1) xD.4255 = {.dataD.4250=0B}; bitsizetype D.4401; sizetype D.4402; D.4401 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <.y4D.4222> * 8; D.4402 = (sizetype) NON_LVALUE_EXPR <.y4D.4222>; s1D.4220 (); s2D.4218 (); s3D.4216 (); s4D.4214 (); } Now, if that .y4 randomly called based on one of the associate users is just named character length of the x array (shouldn't it be called .x ?) of a SAVE var in p, I'd think it should go to the BLOCK where x is defined and nowhere else, all the nested functions (== contained subroutines) should refer to it non-locally and shouldn't have it in its BLOCK_VARS.