Hi,

On 10/18/2012 03:17 AM, Jason Merrill wrote:
Hmm, I thought I fixed a very similar bug recently.

I'm concerned that this change will cause problems with brace-elision situations. But then again, can we have a zero-length array followed by anything else?
If I understand correctly your hesitations, I don't think there are exceptions to the general rule that if the size of the array is zero there can be no initializers. This morning I investigated in some detail this special case (from a testcase I recently added, pr43765.C):

struct SomeType
{
  const char *values[];
};

it's in fact related because we parse it as:

struct SomeType
{
  const char *values[0];
};

(per grokdeclarator around line 10246). Given the way we parse it (not completely uncontroversial, IMHO, but that would be a separate issue), we do the right thing, we accept:

SomeType s = { };

and we reject:

SomeType s = { 1 };

Only the wording of the error changes (from "too many initializers" to "initializers provided") (*)

In any case, I can't imagine a different, safer, way to handle the issue we are facing. Do you have anything specific to suggest?

Thanks,
Paolo.

(*) Moreover we likewise accept:

SomeType s = { {  } };

and likewise reject:

SomeType s = { { { } } };

Reply via email to