https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128397
--- Comment #1 from Christopher Albert <albert at tugraz dot at> --- Open for review, comments welcome: https://github.com/lazy-fortran/gcc/pull/49 This is the patch announced in comment 0. gfc_defer_symbol_init keeps automatic objects (non-constant bounds or character length) in reverse declaration order among themselves in the deferred-init chain, so their prepended setup code runs in declaration order. Other variables keep their relative order; ordering all locals instead broke finalize_17.f90. Objects depending on an old-style function result still take the unchanged fn_result_dep path from PR59104; such a case fails at -O2 with and without the patch. Tested on x86_64-linux against r17-5872: check-gfortran and check-target-libgomp-fortran show no new failures; new test gfortran.dg/pr128397.f90. The patch was written with AI assistance (Claude) and changes 24 lines outside the testsuite, so under https://gcc.gnu.org/ai-policy.html it is not attached here.
