This is the mail archive of the gcc-patches@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]

Re: RFC (c): PATCH for c++/53220 (array compound literals and C++)


On Sat, 26 May 2012, Jason Merrill wrote:

> In C++, C99 a compound literal creates a temporary object, unlike C, where it
> creates an automatic or static object.  As a result, using an array compound
> literal to initialize a pointer variable leads to undefined behavior, as the
> array's lifetime ends after the declaration statement.  This patch changes the
> C++ front end to reject decay of temporary array compound literals to
> pointers, and the C front end to warn about it with -Wc++-compat.
> 
> Tested x86_64-pc-linux-gnu.  Is the C front-end change OK?

The C front-end change is OK.

-- 
Joseph S. Myers
joseph@codesourcery.com


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