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

--- Comment #3 from Max Enrico Winkler <mwinkler at blizzard dot com> ---
> Yes this sounds like you are runing into what I have described as being 
> undefined behavior.

Understood and agreed.

However this specific example is an object that effectively does no work on
destruction.
We would expect the object to be embedded in the binary and not rely on static
de-init order since there should be nothing running during destruction.

With `-O2` the vtable writes get dead store removed and the destructor ends up
being a full nop as expected.

Clang and MSVC have this behaviour and clang also provides more control with
the `no_destroy` attribute.

In general we didn't expect to have static de-init issues with an object of
this type since we didn't expect anything to be running during destruction.

We are aware of the various ways to work around static [de]-init issues but I
ultimately think GCC just shouldn't be overwriting vtables on destruction here.

If you guys think otherwise no worries we can work-around it.

Reply via email to