public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/12277] New: Warn on dynamic casts with known NULL results. @ 2003-09-14 16:55 tilps at hotmail dot com 2003-09-14 17:23 ` [Bug c++/12277] " pinskia at gcc dot gnu dot org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: tilps at hotmail dot com @ 2003-09-14 16:55 UTC (permalink / raw) To: gcc-bugs PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12277 Summary: Warn on dynamic casts with known NULL results. Product: gcc Version: 3.4 Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tilps at hotmail dot com CC: gcc-bugs at gcc dot gnu dot org While this can not be done generally - if the inheritence relation between the type being cast from and the type being cast to is known at the time of use, there are some cases where a dynamic cast can be sure to return NULL. I can not think of any valid use of a dynamic cast which will always return NULL - so therefore I suggest that a warning be given. The specific case which bothered me (and hence why i'm writing this) is upcasting through private inheritence always gives NULL for dynamic cast. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/12277] Warn on dynamic casts with known NULL results. 2003-09-14 16:55 [Bug c++/12277] New: Warn on dynamic casts with known NULL results tilps at hotmail dot com @ 2003-09-14 17:23 ` pinskia at gcc dot gnu dot org 2003-09-15 0:42 ` bangerth at dealii dot org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu dot org @ 2003-09-14 17:23 UTC (permalink / raw) To: gcc-bugs PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12277 pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/12277] Warn on dynamic casts with known NULL results. 2003-09-14 16:55 [Bug c++/12277] New: Warn on dynamic casts with known NULL results tilps at hotmail dot com 2003-09-14 17:23 ` [Bug c++/12277] " pinskia at gcc dot gnu dot org @ 2003-09-15 0:42 ` bangerth at dealii dot org 2004-05-20 12:12 ` pinskia at gcc dot gnu dot org 2004-05-20 13:25 ` pinskia at gcc dot gnu dot org 3 siblings, 0 replies; 5+ messages in thread From: bangerth at dealii dot org @ 2003-09-15 0:42 UTC (permalink / raw) To: gcc-bugs PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12277 bangerth at dealii dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed| |1 Last reconfirmed|0000-00-00 00:00:00 |2003-09-15 00:15:55 date| | ------- Additional Comments From bangerth at dealii dot org 2003-09-15 00:15 ------- Seems reasonable. W. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/12277] Warn on dynamic casts with known NULL results. 2003-09-14 16:55 [Bug c++/12277] New: Warn on dynamic casts with known NULL results tilps at hotmail dot com 2003-09-14 17:23 ` [Bug c++/12277] " pinskia at gcc dot gnu dot org 2003-09-15 0:42 ` bangerth at dealii dot org @ 2004-05-20 12:12 ` pinskia at gcc dot gnu dot org 2004-05-20 13:25 ` pinskia at gcc dot gnu dot org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-05-20 12:12 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-05-19 13:30 ------- *** Bug 15541 has been marked as a duplicate of this bug. *** -- What |Removed |Added ---------------------------------------------------------------------------- CC| |bangerth at dealii dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12277 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/12277] Warn on dynamic casts with known NULL results. 2003-09-14 16:55 [Bug c++/12277] New: Warn on dynamic casts with known NULL results tilps at hotmail dot com ` (2 preceding siblings ...) 2004-05-20 12:12 ` pinskia at gcc dot gnu dot org @ 2004-05-20 13:25 ` pinskia at gcc dot gnu dot org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-05-20 13:25 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-05-19 13:31 ------- And here is an example: struct Base { virtual ~Base () {} }; class Derived : Base { friend int main (); }; #include <cassert> int main () { Base * p = new Derived; assert(dynamic_cast<Derived *>(p)); // fails } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12277 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-05-19 13:32 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-09-14 16:55 [Bug c++/12277] New: Warn on dynamic casts with known NULL results tilps at hotmail dot com 2003-09-14 17:23 ` [Bug c++/12277] " pinskia at gcc dot gnu dot org 2003-09-15 0:42 ` bangerth at dealii dot org 2004-05-20 12:12 ` pinskia at gcc dot gnu dot org 2004-05-20 13:25 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).