« Return to Thread: [Bug c++/12277] Warn on dynamic casts with known NULL results.

[Bug c++/12277] Warn on dynamic casts with known NULL results.

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View in Thread



------- Comment #5 from jason at gcc dot gnu dot org  2009-07-06 20:45 -------
This is only known to be NULL if we know the dynamic type of p.  Consider:

struct Foo: Base {};
struct Bar: Derived, Foo {};

Bar bar;
Base *p2 = (Foo*)&bar;

A dynamic_cast to Derived from p2 should succeed.  But it still seems
reasonable to give a warning for pinskia's testcase.


--


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

 « Return to Thread: [Bug c++/12277] Warn on dynamic casts with known NULL results.