[Bug fortran/68225] ICE with -Wrealloc-lhs-all on structure constructor with allocatable components

gerhard.steinmetz.fortran@t-online.de gcc-bugzilla@gcc.gnu.org
Thu Nov 5 20:52:00 GMT 2015


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

--- Comment #2 from Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de> ---
Here, one or both components are initialized :

$ cat z1.f90
program p
   type t
      integer, allocatable :: a
   end type
   type, extends(t) :: t2
      integer, allocatable :: b
   end type
   type(t2) :: x
   x = t2(1)
   print *, allocated(x%a), x%a
   print *, allocated(x%b), x%b
end

$ gfortran -g -O0 -Wall -Wrealloc-lhs-all z1.f90
...
in gfc_format_decoder, at fortran/error.c:1124

---

$ cat z2.f90
program p
   type t
      integer, allocatable :: a
   end type
   type, extends(t) :: t2
      integer, allocatable :: b
   end type
   type(t2) :: x
   x = t2(1, 2)
   print *, allocated(x%a), x%a
   print *, allocated(x%b), x%b
end


$ gfortran -g -O0 -Wall -Wrealloc-lhs-all z2.f90
z2.f90:9:13:

    x = t2(1, 2)
             1
Warning: Code for reallocating the allocatable variable at (1) will be added
[-Wrealloc-lhs-all]

# ... or ...
$ gfortran -g -O0 -Wall -fcheck=all z1.f90
# ... or ...
$ gfortran -g -O0 -Wall -fcheck=all z2.f90
# ...
# generate a binary a.out -- that always signals SIGSEGV.


$ a.out

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x2B6933228507
#1  0x2B6933227700
#2  0x2B6933CB91FF
#3  0x2B69332F4550
#4  0x2B69332F7DED
#5  0x2B69332F982E
#6  0x400AB4 in p at z2.f90:10 (discriminator 6)
Segmentation fault


More information about the Gcc-bugs mailing list