https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108454

--- Comment #2 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #1)
> The code crashing gfortran may actually be valid.

I set a breakpoint in parse.cc:7386
Breakpoint 1, gfc_parse_file () at ../../gcc-trunk/gcc/fortran/parse.cc:7386
7386      gfc_resolve (gfc_current_ns);
(gdb) l
7381        }
7382
7383      /* Handle the non-program units.  */
7384      gfc_current_ns->code = s.head;
7385
7386      gfc_resolve (gfc_current_ns);
7387
7388      /* Fix the implicit_pure attribute for those procedures who should
7389         not have it.  */
7390      while (gfc_fix_implicit_pure (gfc_current_ns))
(gdb) call gfc_dump_parse_tree (gfc_current_ns, stdout)

This gives a sane dump.

Now repeating this call after the gfc_resolve in line 7386, the debugged
f951 segfaults.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000eb8aa3 in show_common (st=0x4aae700)
    at ../../gcc-trunk/gcc/fortran/dump-parse-tree.cc:1388
1388          fprintf (dumpfile, "%s", s->name);
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(gfc_dump_parse_tree(gfc_namespace*, _IO_FILE*)) will be abandoned.
When the function is done executing, GDB will silently stop.

It looks like the resolution corrupts the namespace.

If one references the variable 't' in the subroutine (e.g., print *,t),
there is no such problem.

Reply via email to