This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/40076] g++ should not permit types to be defined in compound literals
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 02 May 2012 20:20:53 +0000
- Subject: [Bug c++/40076] g++ should not permit types to be defined in compound literals
- Auto-submitted: auto-generated
- References: <bug-40076-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40076
--- Comment #6 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2012-05-02 20:20:53 UTC ---
(In reply to comment #5)
> That's correct for C++ (by the analogy discussed in this bug report), but
> not for C.
My fault. Clang pays more attention to the file extension than to the driver
used. The correct output for C is:
test.c:1:9: error: initializer element is not a compile-time constant
int i = (struct s3 { int j; }) { 1 }.j;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated
which makes the error clearer than in gcc because of the caret location and the
range (plus the beautiful colors ;-).