Re: Is gcc allowed to eliminate writes in a destructor?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10 June 2015 at 08:16, Norbert Lange wrote:
> But I`d be interested what should/could happen if derived destructors
> already did their work, and foo tries to use RTTI (dynamic_cast,
> typeid). I suspect this is undefined behaviour anyway given that these
> could throw,

That's not undefined behaviour, just ill-advised.

Since C++11 destructors are implicitly noexcept(true) by default, so
if a destructor exits via an exception the runtime will call
std::terminate(). That's perfectly well defined.

> and similarly dangerous as accessing virtual functions
> that might have overrides in the derived classes.

Nothing undefined there either, the dynamic type of the object is
CMyClass after the derived destructor runs, so as long as it isn't
pure virtual you can call the function, but it won't dispatch to the
derived override.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux