This is the mail archive of the 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: Placement new versus flifetime-dse

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 [] describes this.


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