0

Language-lawyer question.

I've just read in Scott Meyerses C++ book that if we try to delete an object through a pointer to a base class without a virtual destructor we'll get UB. Ok, now I'm looking for the explanation of the fact that the behavior is actually undefined. Here's what I've found:

the behavior is undefined if the destructor is invoked for an object whose lifetime has ended

and this

if the object is not of the destructor’s class type and not of a class derived from the destructor’s class type (including when the destructor is invoked via a null pointer value), the program has undefined behavior.

in the section about destructors (12.4). But this references don't explain deletion through the base class. Couldn't you provide some explanation in the Standard? Does it actually define that?

St.Antario
  • 26,175
  • 41
  • 130
  • 318

0 Answers0