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

[Bug c++/61982] Optimizer does not eliminate stores to destroyed objects


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61982

--- Comment #17 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And, GCC offers the -fno-lifetime-dse option which will not eliminate the
stores:
-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.  To
preserve stores before the constructor starts (e.g. because your operator new
clears the object storage) but still treat the object as dead after the
destructor you, can use -flifetime-dse=1.  The default behavior can be
explicitly selected with -flifetime-dse=2.  -flifetime-dse=0 is equivalent to
-fno-lifetime-dse.

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