Split off from PR 41872.
The following program fails because of:
static struct .class.t.a a = {.$vptr=0B};
That is: Only $vptr and not also $data is initialized by NULL. Thus:
if (a.$data == 0B)
fails. The initialization is seemingly done in gfc_build_class_symbol, but I do
not see ad hoc why it does not work.
* * *
Replacing the variable by an array ("... :: a(:)" and "allocate (t :: a(1))")
leads to an ICE:
sub2.f90:20:0: internal compiler error: in gfc_conv_descriptor_data_get, at
fortran/trans-array.c:147
* * *
program test
implicit none
type t
end type t
call sub (0)
call sub (1)
call sub (2)
contains
subroutine sub (no)
integer, intent(in) :: no
class(t), allocatable, save :: a
if (no == 0) then
if (allocated (a)) call abort ()
allocate (t :: a)
else if (no == 1) then
if (.not. allocated (a)) call abort ()
deallocate (a)
else
if (allocated (a)) call abort ()
end if
end subroutine sub
end program test
--
Summary: [OOP] CLASS with ALLOCATABLE + SAVE: Not initialized /
ICE
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Keywords: wrong-code, ice-on-valid-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: burnus at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42610