[Bug c++/15541] New: No warning if static checking can tell that a dynamic_cast will fail

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Thu May 20 09:02:00 GMT 2004


Per conclusion from PR 15531: 
 
In this code, the dynamic_cast will always fail: 
------------------------- 
struct Base 
  { 
    virtual ~Base () {} 
  }; 
 
  class Derived : Base 
  { 
    friend int main (); 
  }; 
 
  #include <cassert> 
 
  int main () 
  { 
    Base * p = new Derived; 
 
    assert(dynamic_cast<Derived *>(p)); // fails 
  } 
------------ 
We should issue a warning about this, but don't. 
 
W.

-- 
           Summary: No warning if static checking can tell that a
                    dynamic_cast will fail
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at dealii dot org
                CC: gcc-bugs at gcc dot gnu dot org,gccbugs at contacts dot
                    eelis dot net,gdr at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15541



More information about the Gcc-bugs mailing list