This is the mail archive of the
mailing list for the GCC project.
Placement new versus flifetime-dse
- From: Andrew Haley <aph at redhat dot com>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Tue, 16 Feb 2016 13:04:06 +0000
- Subject: Placement new versus flifetime-dse
- Authentication-results: sourceware.org; auth=none
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:
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.