This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14263] New: Cryptic diagnostic for cast from virtual base class not using dynamic_cast
- From: "gdr at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Feb 2004 21:03:32 -0000
- Subject: [Bug c++/14263] New: Cryptic diagnostic for cast from virtual base class not using dynamic_cast
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider the testcase below
struct A { };
struct B : virtual A { };
int main()
{
A* p = new B;
B* q = static_cast<B*>(p); // #1
}
Line #1 is ill-formed and correctly rejected by the compiler, but
the diagnostic is at best cryptic. I think it should have said
something related to "static_cast".
error: invalid 'static_cast' from virtual base class to derived
class
note: cast from virtual base class to derived class requires use
of 'dynamic_cast'
--
Summary: Cryptic diagnostic for cast from virtual base class not
using dynamic_cast
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gdr at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14263