This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFC (c): PATCH for c++/53220 (array compound literals and C++)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 26 May 2012 19:13:28 +0000 (UTC)
- Subject: Re: RFC (c): PATCH for c++/53220 (array compound literals and C++)
- References: <4FC128AB.1020303@redhat.com>
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