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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|jason at redhat dot com     |jason at gcc dot gnu.org
   Target Milestone|4.7.1                       |4.8.0

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2012-05-07 
14:29:52 UTC ---
Compound literals are not part of C++, so correctness is a matter of debate. 
In C, a compound literal designates an object with automatic storage duration. 
In G++, a compound literal designates a temporary object, just like a normal
cast or function-like cast.

This is a significant difference in semantics, which leads to the problem
encountered here; the temporary object goes out of scope immediately after the
initialization of p, so the loop has undefined behavior.

It would be possible for G++ to model the C semantics more closely.

Reply via email to