http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43453

--- Comment #3 from Johannes Schaub <schaub-johannes at web dot de> 2010-10-30 
09:41:36 UTC ---
(In reply to comment #2)
> (In reply to comment #1)
> > (In reply to comment #0)
> > > Fails to compile, but should work:
> > > 
> > > struct A { 
> > >   char x[4]; 
> > >   A():x("bug") { } 
> > > };
> > > 
> > > Error i get is:
> > > 
> > > "main.cpp:3: error: array used as initializer"
> > > 
> > 
> > Why do you think it should work?  
> > For example, the following equivalent code is invalid as well:
> > 
> > char x [4] ("bug");
> > 
> 
> This code is equivalent and is valid. At least, I don't see the Standard
> forbidding it. GCC is the only compiler I tested (comeau/edg, clang) that
> rejects it.

I'm not actually sure anymore about the validity of this code. One can make a
point about the initializer not being a mere string literal.

At least the draft n3126 makes a difference of this, in that an initializer
like "({a, b, c})" is not regarded as a braced-init-list, but rather as a
parenthesized expression-list where the initializer list is handed as one
argument. So I'm unsure whether an initializer like `("foo")` should be
regarded as a string literal or not.

I think I will send an issue report about this.

Reply via email to