dynamic_cast bug? Feature?

llewelly@dbritsch.dsl.xmission.com llewelly@dbritsch.dsl.xmission.com
Sat Jul 22 20:02:00 GMT 2000


On Thu, 20 Jul 2000, Bruce Ide wrote:

> I've got a bit of C++ code here that exits with a compiler error in GCC
> 2.95.2. Shouldn't this compile and have dynamic_cast return a 0 for the
> class the compiler's erroring on?
> 
> 

For an expression of the form dynamic_cast<T*>(v), v must be a pointer to
  a type derived from T, a pointer to polymorphic type, or T* must be
  void*

CantPing is not a polymorphic type (no virtual functions), and Pinger is
  not a base class of CantPing.

(See 5.2.1, paragraph 6)

So your code is ill-formed, and this is not a bug in gcc.

Thank you for your bug report.





More information about the Gcc-bugs mailing list