This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Placement new versus flifetime-dse
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Tue, 16 Feb 2016 14:16:54 +0100
- Subject: Re: Placement new versus flifetime-dse
- Authentication-results: sourceware.org; auth=none
- References: <56C31E46 dot 9030205 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Feb 16, 2016 at 01:04:06PM +0000, Andrew Haley wrote:
> I'm fixing a bug which involves initialization of a field of an object
> in its placement new function before the constructor is called. This
> is falling foul of DSE, which deletes the field initialization.
>
> I see this:
>
> @item -fno-lifetime-dse
> @opindex fno-lifetime-dse
> In C++ the value of an object is only affected by changes within its
> lifetime: when the constructor begins, the object has an indeterminate
> value, and any changes during the lifetime of the object are dead when
> the object is destroyed. Normally dead store elimination will take
> advantage of this; if your code relies on the value of the object
> storage persisting beyond the lifetime of the object, you can use this
> flag to disable this optimization.
>
> I'm quite happy to believe this, and treat my bug simply as an error
> between chair and keyboard, but I cannot find the language in the C++
> standard which declares that the lifetime of an object begins with its
> constructor, and thus any stores into the object performed by
> placement new may be deleted.
>
> Can someone please tell me Chapter and Verse in the standard, please?
> Then I can close this one.
I'd think [basic.life] describes this.
Jakub