This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/57599] g++ accepts invalid dynamic_cast of a const type to a regular type
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 12 Jun 2013 16:34:59 +0000
- Subject: [Bug c++/57599] g++ accepts invalid dynamic_cast of a const type to a regular type
- Auto-submitted: auto-generated
- References: <bug-57599-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57599
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The summary is very misleading. You're not casting a const type to a non-const
type, you're casting a non-const type to a const type, then assigning that to a
non-const type.
What actually happens is that dynamic_cast<const A*>(b) returns A*