[Bug c++/68164] Destructor side effect unexpectedly elided

Casey at Carter dot net gcc-bugzilla@gcc.gnu.org
Mon Nov 2 05:50:00 GMT 2015


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

Casey Carter <Casey at Carter dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Casey at Carter dot net

--- Comment #1 from Casey Carter <Casey at Carter dot net> ---
[basic.life]/5 says:

Before the lifetime of an object has started ... or, after the lifetime of an
object has ended and before the storage which the object occupied is reused or
released, any pointer that refers to the storage location where the object will
be or was located may be used but only in limited ways. ... Indirection through
such a pointer is permitted but the resulting lvalue may only be used in
limited ways, as described below. The program has undefined behavior if:

(5.1) — ...

(5.2) — the pointer is used to access a non-static data member or call a
non-static member function of the object, or

...

This looks like straight-forward violation of 5.2 resulting in UB.


More information about the Gcc-bugs mailing list