Re: check that a member function really operates on an object of the expected type

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

 



Erik <esigra@xxxxxxxxx> writes:

> This will throw std::bad_cast if the bug in question is encountered. Of
> course it is not practically possible to add such an assertion to the
> beginning of every method, but there should be a compiler flag to enable
> this (in debug builds). Is there such a flag? Is there a feature request
> for it?

There is no such flag or feature request.  Moreover, even if there were
such a flag, it would not work reliably for your example.  If an object
has been destroyed, what dynamic_cast will return is essentially random.
I would argue against adding such a feature to the compiler.  This is an
area better addressed by -fmudflap or valgrind.

Ian

[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