Why does debugging "pure virtual method called" have to be so hard?
Alexandre Oliva
oliva@dcc.unicamp.br
Mon Oct 26 02:13:00 GMT 1998
Jason Merrill <jason@cygnus.com> writes:
>>>>>> Mike Stump <mrs@wrs.com> writes:
>> How to others feel about calling abort instead of _exit? abort might
>> be more useful.
> I would prefer terminate.
But [lib.terminate] says:
1 Called by the implementation when exception handling must be abandoned
for any of several reasons (_except.terminate_). May also be called
directly by the program.
Calling a pure virtual function is not a case of exception handling,
so it might be strange to call it in such a situation. Of course, one
may argue that calling a pure virtual function has undefined behavior,
and so it *may* call terminate(), but that's not what one would
expect, so I'd rather modify __pure_virtual() so that it calls abort()
or throws an exception of some non-standard type, say,
__pure_virtual_exception, which may end up turning into a call of
unexpected(), then terminate().
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:oliva@gnu.org mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
More information about the Gcc
mailing list