[Bug fortran/68225] ICE with -Wrealloc-lhs-all on structure constructor with allocatable scalar component(s)

2016-12-08 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68225

--- Comment #8 from Gerhard Steinmetz  
---
Addendum  :


$ cat zzp.f90
program p
   type t
  integer :: a
  character(:), allocatable :: c
   end type
   type(t) :: x
   x = t(a=1)   ; print *, x%a, x%c
   x = t(a=2, c=null()) ; print *, x%a, x%c
   x = t(c=null(), a=3) ; print *, x%a, x%c
   x = t(a=4, c='c4')   ; print *, x%a, x%c
   x = t(a=5)   ; print *, x%a, x%c
   x = t(6, 'c6')   ; print *, x%a, x%c
   x = t(c='c7', a=7)   ; print *, x%a, x%c
   x = t(c=null(), a=8) ; print *, x%a, x%c
   x = t(9, c='c9') ; print *, x%a, x%c
   x = t(10, null()); print *, x%a, x%c
   x = t(11, 'c11') ; print *, x%a, x%c
   x = t(12); print *, x%a, x%c
end


$ gfortran-7-20161204 -O2 zzp.f90
$ a.out
   1
   2
   3
   4 c4
   5
   6 c6
   7 c7
   8
   9 c9
  10
  11 c11
  12



Compiling with -O0 or -Og :

$ gfortran-7-20161204 -g -O0 -Wall -fcheck=all zzp.f90
$ a.out
   1
   2

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

Backtrace for this error:
#0  0x2ad486c4711f in ???
#1  0x2ad486ca38ee in ???
#2  0x410f1a in list_formatted_write_scalar
at ../../../libgfortran/io/write.c:1887
#3  0x4023d7 in p
at .../zzp.f90:9
#4  0x402e53 in main
at .../zzp.f90:19
Segmentation fault

[Bug fortran/68225] ICE with -Wrealloc-lhs-all on structure constructor with allocatable scalar component(s)

2016-12-08 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68225

--- Comment #7 from Gerhard Steinmetz  
---
*** Bug 68439 has been marked as a duplicate of this bug. ***

[Bug fortran/68225] ICE with -Wrealloc-lhs-all on structure constructor with allocatable scalar component(s)

2016-08-22 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68225

--- Comment #6 from Gerhard Steinmetz  
---
ICE seems to be gone, z1 now and z2 still aborting at runtime.
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

[Bug fortran/68225] ICE with -Wrealloc-lhs-all on structure constructor with allocatable scalar component(s)

2015-11-09 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68225

--- Comment #5 from Gerhard Steinmetz  
---
$ cat yy0.f90
program p
   type t
  integer, allocatable :: a(:)
   end type
   type(t) :: x
   x = t()
   print *, allocated(x%a), x%a
end

$ gfortran -g -O0 -Wall -fcheck=all  yy0.f90
$ a.out
 F

---

$ cat yy1.f90
program p
   type t
  integer, allocatable :: a(:)
   end type
   type(t) :: x
   x = t([1, 2])
   print *, allocated(x%a), x%a
end

$ gfortran -g -O0 -Wall -fcheck=all  yy1.f90
$ a.out
 T   1   2

---

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

$ gfortran -g -O0 -Wall -fcheck=all  zz0.f90
$ a.out
 F
 F

---

$ cat zz1.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 -fcheck=all  zz1.f90
$ a.out
 T   1
 F

---

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

$ gfortran -g -O0 -Wall -fcheck=all  zz2.f90
$ a.out
 F
 T   1   2