On 12/09/2016 08:09 AM, Jakub Jelinek wrote:
On Fri, Dec 09, 2016 at 08:04:11AM -0700, Martin Sebor wrote:
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") {}
};
Sure, that has a clear meaning.
then (IMO) so is this:
struct Foo {
int a;
char ary[];
Foo () : ary ("bob") {}
};
So what does this mean? Assume that the Foo object lives on the heap
and has been allocated with extra space after it? Or shall global/automatic
objects of type Foo be allocated with the extra space (like
struct Foo x = { 5, "bob" }; in C would do if the Foo () ... line is
removed?
Something different?
It means the same thing as the first case, down to sizeof (Foo).
All of Foo's ctors would have to agree on the size of the initializer
(with an error if they didn't and could be seen in the same translation
unit). In most cases the notation from the bug report would then be
the preferred one to use.
struct Foo {
int a;
char ary[] = "bob";
Foo () { }
};
Martin