This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]