This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/42610] [OOP] CLASS with ALLOCATABLE + SAVE: Not initialized / ICE
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Jan 2010 09:53:49 -0000
- Subject: [Bug fortran/42610] [OOP] CLASS with ALLOCATABLE + SAVE: Not initialized / ICE
- References: <bug-42610-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from burnus at gcc dot gnu dot org 2010-01-06 09:53 -------
I think the function causing the trouble is gfc_conv_structure (with init=1).
The following is simply not true:
/* Skip absent members in default initializers and allocatable
components. Although the latter have a default initializer
of EXPR_NULL,... by default, the static nullify is not needed
since this is done every time we come into scope. */
if (!c->expr || cm->attr.allocatable)
continue;
I think, one was thinking of:
static struct .class.t.a a = {.$vptr=0B};
a.$data = 0B
but the last line may not be present for SAVE.
Thus this comment should be completely bogus!
Interestringly, it works
type(t), allocatable, save :: a(:)
which is probably an array feature.
And for
type t
integer, allocatable :: a
end type t
type(t), save :: a
it works because
static struct t a = {};
is used to initialize -- and {} sets all bytes of the struct to 0 -- that would
be an alternative also here; e.g.
if (expr->ts.type == CLASS
&& expr->ts->u.derived.name contains ".a")
use "= {}"
initializer.
Otherwise, one could use:
if (cm->allocatable && expr->ts.type == CLASS)
use initializer instead of "break".
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42610