This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: dynamic_cast bug? Feature?
- To: Bruce Ide <nride at uswest dot net>
- Subject: Re: dynamic_cast bug? Feature?
- From: llewelly at dbritsch dot dsl dot xmission dot com
- Date: Sat, 22 Jul 2000 20:03:23 -0600 (MDT)
- Cc: gcc-bugs at gcc dot gnu dot org
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.