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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is NOT a GCC bug. Rather it is a bug which depends on stuff like:
         // mLength is initialized by operator new()

inside `StringData( const StringChar* data, bool interned = false )`. Before
the constructor, nothing can be assumed to be initialized so the store for
mLength which was in the "operator new" is being deleted as being dead.

You can workaround this undefined code by using -flifetime-dse=1 as described
in
https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gcc/Optimize-Options.html#index-flifetime-dse
:
```
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.
```

Reply via email to