On 12/09/2016 05:34 AM, Nathan Sidwell wrote:
On 12/08/2016 03:42 PM, Martin Sebor wrote:
On 12/08/2016 01:28 PM, Marek Polacek wrote:
On Thu, Dec 08, 2016 at 02:56:56PM -0500, Nathan Sidwell wrote:

struct Foo {
int a;
char ary[];
Foo () : ary ("bob"){}

Clang accepts this test case although it does reject the originally
submitted test case with the messages below.  I think GCC should
accept the latter case for compatibility.  If it is accepted then
rejecting the original test case will make the array initialization
irregular.  I think it would be nice if they both could accepted
but I don't know how much work it would be to make it work.

I think all these should be rejected for the same reason -- they're
equally unmeaningfull.  The string being used must be a string literal
-- not a pointer to a caller-provided string, or template argument
(which I could see as plausible use cases).  So the problem is being
baked into the class or ctor definition.

I'm not sure I understand what you mean.  Since the following is
valid and meaningful (i.e., initializes the array with  the elements
of the string):

  struct Foo {
   int a;
   char ary[4];
   Foo () : ary ("bob") {}
  };

then (IMO) so is this:

  struct Foo {
   int a;
   char ary[];
   Foo () : ary ("bob") {}
  };

Martin

PS I do agree that it's probably too late to make this work for GCC
7 and that rejecting it is better than an ICE.

Reply via email to