https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104228
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The .y var is added into the s function with: #0 add_decl_as_local (decl=<var_decl 0x7fffea24ab40 .y>) at ../../gcc/fortran/trans-decl.cc:257 #1 0x0000000000c054f8 in gfc_finish_var_decl (decl=<var_decl 0x7fffea24ab40 .y>, sym=0x3e16a00) at ../../gcc/fortran/trans-decl.cc:649 #2 0x0000000000c09e9e in gfc_get_symbol_decl (sym=0x3e16a00) at ../../gcc/fortran/trans-decl.cc:1882 #3 0x0000000000c18dee in generate_local_decl (sym=0x3e16a00) at ../../gcc/fortran/trans-decl.cc:5853 #4 0x0000000000bb5174 in do_traverse_symtree (st=0x3e16b60, st_func=0x0, sym_func=0xc18d2a <generate_local_decl(gfc_symbol*)>) at ../../gcc/fortran/symbol.cc:4174 #5 0x0000000000bb522f in gfc_traverse_ns (ns=0x3e19810, sym_func=0xc18d2a <generate_local_decl(gfc_symbol*)>) at ../../gcc/fortran/symbol.cc:4199 #6 0x0000000000c19780 in generate_local_vars (ns=0x3e19810) at ../../gcc/fortran/trans-decl.cc:6064 #7 0x0000000000c20fae in gfc_process_block_locals (ns=0x3e19810) at ../../gcc/fortran/trans-decl.cc:7940 #8 0x0000000000ca8b60 in gfc_trans_block_construct (code=0x3e16ba0) at ../../gcc/fortran/trans-stmt.cc:2296 #9 0x0000000000bd8645 in trans_code (code=0x3e16ba0, cond=<tree 0x0>) at ../../gcc/fortran/trans.cc:2012 #10 0x0000000000bd8a58 in gfc_trans_code (code=0x3e16ba0) at ../../gcc/fortran/trans.cc:2268 #11 0x0000000000c203ea in gfc_generate_function_code (ns=0x3e15530) at ../../gcc/fortran/trans-decl.cc:7654 #12 0x0000000000c18b5d in gfc_generate_contained_functions (parent=0x3e14530) at ../../gcc/fortran/trans-decl.cc:5777 #13 0x0000000000c20031 in gfc_generate_function_code (ns=0x3e14530) at ../../gcc/fortran/trans-decl.cc:7586 #14 0x0000000000bd8a9c in gfc_generate_code (ns=0x3e14530) at ../../gcc/fortran/trans.cc:2285 #15 0x0000000000b5ca50 in translate_all_program_units (gfc_global_ns_list=0x3e14530) at ../../gcc/fortran/parse.cc:6651 #16 0x0000000000b5d299 in gfc_parse_file () at ../../gcc/fortran/parse.cc:6938 #17 0x0000000000bc0539 in gfc_be_parse_file () at ../../gcc/fortran/f95-lang.cc:216 #18 0x0000000001463e4f in compile_file () at ../../gcc/toplev.cc:452 #19 0x0000000001466e45 in do_compile (no_backend=false) at ../../gcc/toplev.cc:2158 #20 0x000000000146720a in toplev::main (this=0x7fffffffd76a, argc=4, argv=0x7fffffffd878) at ../../gcc/toplev.cc:2310 #21 0x0000000002b3c444 in main (argc=4, argv=0x7fffffffd878) at ../../gcc/main.cc:39 and then pushdecl is called on it too: #0 pushdecl (decl=<var_decl 0x7fffea24ab40 .y>) at ../../gcc/fortran/f95-lang.cc:442 #1 0x0000000000c21086 in gfc_process_block_locals (ns=0x3e19810) at ../../gcc/fortran/trans-decl.cc:7952 #2 0x0000000000ca8b60 in gfc_trans_block_construct (code=0x3e16ba0) at ../../gcc/fortran/trans-stmt.cc:2296 #3 0x0000000000bd8645 in trans_code (code=0x3e16ba0, cond=<tree 0x0>) at ../../gcc/fortran/trans.cc:2012 #4 0x0000000000bd8a58 in gfc_trans_code (code=0x3e16ba0) at ../../gcc/fortran/trans.cc:2268 #5 0x0000000000c203ea in gfc_generate_function_code (ns=0x3e15530) at ../../gcc/fortran/trans-decl.cc:7654 #6 0x0000000000c18b5d in gfc_generate_contained_functions (parent=0x3e14530) at ../../gcc/fortran/trans-decl.cc:5777 #7 0x0000000000c20031 in gfc_generate_function_code (ns=0x3e14530) at ../../gcc/fortran/trans-decl.cc:7586 #8 0x0000000000bd8a9c in gfc_generate_code (ns=0x3e14530) at ../../gcc/fortran/trans.cc:2285 #9 0x0000000000b5ca50 in translate_all_program_units (gfc_global_ns_list=0x3e14530) at ../../gcc/fortran/parse.cc:6651 #10 0x0000000000b5d299 in gfc_parse_file () at ../../gcc/fortran/parse.cc:6938 #11 0x0000000000bc0539 in gfc_be_parse_file () at ../../gcc/fortran/f95-lang.cc:216 #12 0x0000000001463e4f in compile_file () at ../../gcc/toplev.cc:452 #13 0x0000000001466e45 in do_compile (no_backend=false) at ../../gcc/toplev.cc:2158 #14 0x000000000146720a in toplev::main (this=0x7fffffffd76a, argc=4, argv=0x7fffffffd878) at ../../gcc/toplev.cc:2310 #15 0x0000000002b3c444 in main (argc=4, argv=0x7fffffffd878) at ../../gcc/main.cc:39 with cfun->decl of s and once again in: #0 pushdecl (decl=<var_decl 0x7fffea24ab40 .y>) at ../../gcc/fortran/f95-lang.cc:442 #1 0x0000000000c20b7e in gfc_generate_function_code (ns=0x3e14530) at ../../gcc/fortran/trans-decl.cc:7768 #2 0x0000000000bd8a9c in gfc_generate_code (ns=0x3e14530) at ../../gcc/fortran/trans.cc:2285 #3 0x0000000000b5ca50 in translate_all_program_units (gfc_global_ns_list=0x3e14530) at ../../gcc/fortran/parse.cc:6651 #4 0x0000000000b5d299 in gfc_parse_file () at ../../gcc/fortran/parse.cc:6938 #5 0x0000000000bc0539 in gfc_be_parse_file () at ../../gcc/fortran/f95-lang.cc:216 #6 0x0000000001463e4f in compile_file () at ../../gcc/toplev.cc:452 #7 0x0000000001466e45 in do_compile (no_backend=false) at ../../gcc/toplev.cc:2158 #8 0x000000000146720a in toplev::main (this=0x7fffffffd76a, argc=4, argv=0x7fffffffd878) at ../../gcc/toplev.cc:2310 #9 0x0000000002b3c444 in main (argc=4, argv=0x7fffffffd878) at ../../gcc/main.cc:39 with cfun->decl of p.