https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90539
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #39 from kargl at gcc dot gnu.org --- (In reply to Thomas Koenig from comment #38) > So, I finally have a self-contained test case: > > module t2 > implicit none > contains > subroutine foo(a) > real, dimension(*) :: a > end subroutine foo > end module t2 > module t1 > use t2 > implicit none > contains > subroutine bar(a) > real, dimension(:) :: a > call foo(a) > end subroutine bar > end module t1 > > program main > use t1 > call bar([1.0, 2.0]) > end program main This looks an optimizer bug. Compiling with -fdump-tree-original -fdump-tree-optimize -O gives (in a.f90.004t.original) MAIN__ () { { static real(kind=4) A.5[2] = {1.0e+0, 2.0e+0}; struct array01_real(kind=4) parm.6; parm.6.span = 4; parm.6.dtype = {.elem_len=4, .rank=1, .type=3}; parm.6.dim[0].lbound = 0; parm.6.dim[0].ubound = 1; parm.6.dim[0].stride = 1; parm.6.data = (void *) &A.5[0]; parm.6.offset = 0; bar (&parm.6); } } (in a.f90.231t.optimized) main (integer(kind=4) argc, character(kind=1) * * argv) { struct array01_real(kind=4) parm.9; static integer(kind=4) options.10[7] = {2116, 4095, 0, 0, 1, 0, 31}; <bb 2> [local count: 1073741824]: _gfortran_set_args (argc_2(D), argv_3(D)); _gfortran_set_options (7, &options.10[0]); # DEBUG INLINE_ENTRY MAIN__ parm.9.span = 4; MEM[(struct dtype_type *)&parm.9 + 24B] = {}; parm.9.dtype.elem_len = 4; parm.9.dtype.rank = 1; parm.9.dtype.type = 3; parm.9.dim[0].lbound = 0; parm.9.dim[0].ubound = 1; parm.9.dim[0].stride = 1; parm.9.data = &A.8[0]; parm.9.offset = 0; bar (&parm.9); parm.9 ={v} {CLOBBER}; return 0; } Note 'static real(kind=4) A.5[2] = {1.0e+0, 2.0e+0};' in *original appears to be A.8 in *.optimized, but the static declaration is gone. Perhaps, the Fortran FE needs to mark that actual arguments as "used" by gfc_mark_ss_chain_used() or TREE_USED().