This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53220] [4.7/4.8 Regression] g++ mis-compiles compound literals
- From: "xinliangli at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 07 May 2012 17:03:51 +0000
- Subject: [Bug c++/53220] [4.7/4.8 Regression] g++ mis-compiles compound literals
- Auto-submitted: auto-generated
- References: <bug-53220-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53220
--- Comment #7 from davidxl <xinliangli at gmail dot com> 2012-05-07 17:03:51 UTC ---
Yes, the array case should be warned or disallowed if 1 is the way to go.
I won't call it a lousy choice -- the C++ semantics of the compound literals
allow more agressive optimization and smaller stack usage.
David
(In reply to comment #6)
> (In reply to comment #5)
>
> > 1) to keep the current G++ semantics of compound literals, but change its
> > behavior due to the implementation change (with clobber marker);
>
> I would argue that 1 is completely useless for "you can also construct an
> array" use case from http://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html
>
> It always initializes the pointer with dangling storage, and is always a bug.
>
> If "keep the current g++ semantics", then the code should be rejected at
> compile time, and should *not* work when built without optimization.
>
> IMO, having this code working in C and not working in C++ is a lousy choice.