[PATCH] fix #69253 - [6 Regression] ICE in cxx_incomplete_type_diagnostic initializing a flexible array member with empty string

Martin Sebor msebor@gmail.com
Mon Jan 18 19:54:00 GMT 2016


The attached patch fixes the ICE reported for the test case below:

   struct str {
     int a;
     char s[];
   };
   void fn1() { (struct str){1, ""}; }

While I don't think the patch is incorrect as far as it goes, it's
not the last word on the subject of initializing flexible array
members.  I uncovered a number of other problems in this area while
testing the patch.

First, while the patch rejects the submitted test case, it doesn't
reject it when the struct is defined like so:

   struct str {
     char a, s[];
   };

The other problems are variations on the case above that I came
across while testing the patch.  They are summarized in c++69338
- incorrect ctor initialization of a flexible array member.

Since these outstanding problems are not strictly speaking
a regression (the code is accepted in 5.1 with -fpermissive),
rather than working up a more robust fix addressing all of these
issues I think it's probably better to fix just the ICE for now
(because that is a regression) and tackle the remaining problems
at some later point.

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-69253.patch
Type: text/x-patch
Size: 1889 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160118/2024884a/attachment.bin>


More information about the Gcc-patches mailing list