This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Why does debugging "pure virtual method called" have to be so hard?



> Calling a pure virtual function is not a case of exception handling,
> so it might be strange to call it in such a situation.

This is too bad.  I wish the committee had specified that an exception
be thrown here; it would be consistent with the rest of the language.
Everywhere else, if the user does something illegal that can't be caught
at compile time (e.g. bad dynamic cast of a reference), we throw an exception.

> ... calling a pure virtual function has undefined behavior ...
which means we can do what we want.

I vote for
	throw __pure_virtual_exception;

where that class is derived from class std::exception.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]