[Bug c++/14263] New: Cryptic diagnostic for cast from virtual base class not using dynamic_cast

gdr at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Feb 23 21:03:00 GMT 2004


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



More information about the Gcc-bugs mailing list