------- 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

Reply via email to