This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/40076] g++ should not permit types to be defined in compound literals


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

--- Comment #5 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2012-05-02 20:13:02 UTC ---
On Wed, 2 May 2012, manu at gcc dot gnu.org wrote:

> I think this is confirmed. Clang prints:
> 
> pr40076.cc:1:17: error: 's3' can not be defined in a type specifier
> int i = (struct s3 { int j; }) { 1 }.j;
>                 ^
> 1 error generated.
> 
> for both C and C++.

That's correct for C++ (by the analogy discussed in this bug report), but 
not for C.

> pr40076.cc:1:17: error: initializer element is not constant
>  int i = (struct s3 { int j; }) { 1 }.j;
>                  ^
> 
> which is less clear.

That's a correct error for C, however; C allows types to be defined like 
that in sizeof, casts and compound literals, but that initializer is not 
(required to be) constant in C standard terms.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]