This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/65673] Compound literal with initializer for zero-sized array drops other initializers


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65673

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
What happens here is that pop_init_level returns error_mark_node because
initializing a zero-length array member with {} is discarded:

 7565       /* Silently discard empty initializations.  The parser will
 7566          already have pedwarned for empty brackets.  */
 7567       if (integer_zerop (constructor_unfilled_index))
 7568         constructor_type = NULL_TREE;

thus ret.value is NULL:

 7718   if (ret.value == 0 && constructor_stack == 0)
 7719     ret.value = error_mark_node;
 7720   return ret;

output_init_element then sees that value == error_mark_node, so it marks the
ctor as erroneous:

 8388   if (type == error_mark_node || value == error_mark_node)
 8389     {
 8390       constructor_erroneous = 1;
 8391       return;
 8392     }

And because the ctor is erroneous, we don't build a CONSTRUCTOR for it:

 7668       if (constructor_erroneous)
 7669         ret.value = error_mark_node;
 7670       else
 7671         {
 7672           ret.value = build_constructor (constructor_type,
 7673                                          constructor_elements);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]