[Bug fortran/65173] ICE while compiling wrong code
kargl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Dec 7 21:22:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65173
--- Comment #11 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #10)
> (In reply to Gerhard Steinmetz from comment #9)
> > Another example, together with LANG=de_DE.UTF-8 :
> >
> >
> > $ cat zz1.f90
> > program p
> > type t
> > character, allocatable :: z1(:), z1(:)
> > end type
> > end
> >
> >
> > $ gfortran-7-20161204 -m32 zz1.f90
> > zz1.f90:3:37-44:
> >
> > character, allocatable :: z1(:), z1(:)
> > 2 1
> > Error: Component »z1« at (1) already declared at (2)
> > f951: internal compiler error: Speicherzugriffsfehler
> > 0xc4940f crash_signal
> > ../../gcc/toplev.c:333
> > 0x6f3aea gfc_resolve_expr(gfc_expr*)
> > ../../gcc/fortran/resolve.c:6465
>
> (gdb) bt
> (gdb) bt
> #0 gfc_is_constant_expr (e=0x837f) at ../../gcc7/gcc/fortran/expr.c:894
> #1 0x000000000065a320 in resolve_component (c=0x20365f8c0, sym=0x203635f00)
> at ../../gcc7/gcc/fortran/resolve.c:13507
> #2 0x000000000065a9ab in resolve_fl_derived0 (sym=sym@entry=0x203635f00)
> at ../../gcc7/gcc/fortran/resolve.c:13738
> ...
> (gdb) up
> #1 0x000000000065a320 in resolve_component (c=0x20365f8c0, sym=0x203635f00)
> at ../../gcc7/gcc/fortran/resolve.c:13507
> 13507 || !gfc_is_constant_expr (c->ts.u.cl->length))
> (gdb) p *c->ts.u.cl
> $5 = {length = 0x837f, next = 0x20362b5d0, length_from_typespec = false,
> backend_decl = 0x2039d8040, passed_length = 0x0, resolved = 56844672}
>
> length=0x837f is an invalid pointer. So, gfortran ICE's. This
> looks similar to the fight that Janus waged this weekend. For
> some reason, a CHARACTER(LEN=....) component in a derived type
> does not set the length correctly.
Well, this is due to reject_statement(), which frees memory associated
with charlen. It seems we have a tangling pointer that needs to be
explicitly NULLed, but I cannot find it. If the code is changed to
program p
type t
character, allocatable :: z1(:)
character, allocatable :: z1(:)
end type
end
gfortran generates an error message without the ICE because the
charlen from the first statement is not cleared.
More information about the Gcc-bugs
mailing list