There seems to be something weird going on in gfc_conv_array_initializer. In 
the EXPR_ARRAY case, the code builds both an "index" and a "range". Then, 
optionally, it adds both of them to the constructor list being built. This is 
strange: I would expect either of them to be added, but not both.

A testcase which triggers this behaviour is execute/data.f90. I caught this by 
adding this additional verification hunk in varasm.c (but my tree is not clean 
so I am not sure this is enough):


*************** output_constructor (tree exp, unsigned H
*** 4089,4094 ****
--- 4109,4115 ----
             if each element has the proper size.  */
          if ((field != 0 || index != 0) && pos != total_bytes)
            {
+             gcc_assert (pos >= total_bytes);
              assemble_zeros (pos - total_bytes);
              total_bytes = pos;
            }
*************** output_constructor (tree exp, unsigned H
*** 4164,4169 ****
--- 4185,4191 ----
              /* If still not at proper byte, advance to there.  */
              if (next_offset / BITS_PER_UNIT != total_bytes)
                {
+                 gcc_assert (next_offset / BITS_PER_UNIT >= total_bytes);
                  assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes);
                  total_bytes = next_offset / BITS_PER_UNIT;
                }



Also, gfc_conv_array_initializer, in the EXPR_CONSTANT/EXPR_STRUCTURE case, 
contains some code which builts a repeated initializer by hand. It looks like 
it would be easier but much more memory friendly to just use a RANGE_EXPR.

Steven asked me to assign this to him. This is part of my work to make 
CONSTRUCTOR use VECs (actually, it's the only issue left AFAICT).

-- 
           Summary: gfc_conv_array_initializer weirdness
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: fortran
        AssignedTo: stevenb at suse dot de
        ReportedBy: giovannibajo at libero dot it
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22210

Reply via email to