public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12277] Warn on dynamic casts with known NULL results.
       [not found] <bug-12277-4@http.gcc.gnu.org/bugzilla/>
@ 2013-11-07 10:26 ` paolo.carlini at oracle dot com
  2014-11-27 21:21 ` gcc at dixie dot net.nz
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-11-07 10:26 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12277] Warn on dynamic casts with known NULL results.
       [not found] <bug-12277-4@http.gcc.gnu.org/bugzilla/>
  2013-11-07 10:26 ` [Bug c++/12277] Warn on dynamic casts with known NULL results paolo.carlini at oracle dot com
@ 2014-11-27 21:21 ` gcc at dixie dot net.nz
  2014-11-27 21:23 ` gcc at dixie dot net.nz
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: gcc at dixie dot net.nz @ 2014-11-27 21:21 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Dixie <gcc at dixie dot net.nz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gcc at dixie dot net.nz

--- Comment #7 from Andrew Dixie <gcc at dixie dot net.nz> ---
With final, I believe the following dynamic_cast must always return NULL:

struct a1 { virtual ~a1() {} };
struct a2 final { virtual ~a2() {} };

bool test(a1 *x)
{
        return dynamic_cast<a2 *>(x) != 0;
}


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12277] Warn on dynamic casts with known NULL results.
       [not found] <bug-12277-4@http.gcc.gnu.org/bugzilla/>
  2013-11-07 10:26 ` [Bug c++/12277] Warn on dynamic casts with known NULL results paolo.carlini at oracle dot com
  2014-11-27 21:21 ` gcc at dixie dot net.nz
@ 2014-11-27 21:23 ` gcc at dixie dot net.nz
  2014-11-28  8:44 ` ville.voutilainen at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: gcc at dixie dot net.nz @ 2014-11-27 21:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Andrew Dixie <gcc at dixie dot net.nz> ---
Created attachment 34130
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34130&action=edit
dynamic_cast warning


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12277] Warn on dynamic casts with known NULL results.
       [not found] <bug-12277-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2014-11-27 21:23 ` gcc at dixie dot net.nz
@ 2014-11-28  8:44 ` ville.voutilainen at gmail dot com
  2021-02-11 23:28 ` [Bug c++/12277] eliminate and warn " msebor at gcc dot gnu.org
  2021-10-01 10:22 ` egallager at gcc dot gnu.org
  5 siblings, 0 replies; 14+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-11-28  8:44 UTC (permalink / raw)
  To: gcc-bugs

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

Ville Voutilainen <ville.voutilainen at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ville.voutilainen at gmail dot com

--- Comment #9 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
(In reply to Andrew Dixie from comment #7)
> With final, I believe the following dynamic_cast must always return NULL:
> 
> struct a1 { virtual ~a1() {} };
> struct a2 final { virtual ~a2() {} };
> 
> bool test(a1 *x)
> {
>         return dynamic_cast<a2 *>(x) != 0;
> }

If a1 is final, sure. Whether a2 is final is irrelevant.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12277] eliminate and warn on dynamic casts with known NULL results
       [not found] <bug-12277-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2014-11-28  8:44 ` ville.voutilainen at gmail dot com
@ 2021-02-11 23:28 ` msebor at gcc dot gnu.org
  2021-10-01 10:22 ` egallager at gcc dot gnu.org
  5 siblings, 0 replies; 14+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-02-11 23:28 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2017-01-11 00:00:00         |2021-2-11
      Known to fail|7.0                         |11.0, 7.5.0

--- Comment #11 from Martin Sebor <msebor at gcc dot gnu.org> ---
No improvement in GCC 11.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12277] eliminate and warn on dynamic casts with known NULL results
       [not found] <bug-12277-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2021-02-11 23:28 ` [Bug c++/12277] eliminate and warn " msebor at gcc dot gnu.org
@ 2021-10-01 10:22 ` egallager at gcc dot gnu.org
  5 siblings, 0 replies; 14+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-10-01 10:22 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #12 from Eric Gallager <egallager at gcc dot gnu.org> ---
Would this warning go under an existing flag, or a new one?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12277] Warn on dynamic casts with known NULL results.
       [not found] <bug-12277-3548@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2009-07-06 20:45 ` jason at gcc dot gnu dot org
@ 2009-07-06 20:56 ` bangerth at gmail dot com
  3 siblings, 0 replies; 14+ messages in thread
From: bangerth at gmail dot com @ 2009-07-06 20:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from bangerth at gmail dot com  2009-07-06 20:56 -------
(In reply to comment #3)

I had to stare at the testcase in comment #3 for a little while and thought
others may have to as well: it fails because the inheritance from Base is
*private*, not because the dynamically created object is not derived a Derived
object at all.

W.


-- 


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12277] Warn on dynamic casts with known NULL results.
       [not found] <bug-12277-3548@http.gcc.gnu.org/bugzilla/>
  2005-11-26  8:05 ` [Bug c++/12277] Warn " gdr at gcc dot gnu dot org
  2007-06-11 11:19 ` pinskia at gcc dot gnu dot org
@ 2009-07-06 20:45 ` jason at gcc dot gnu dot org
  2009-07-06 20:56 ` bangerth at gmail dot com
  3 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-07-06 20:45 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12277] Warn on dynamic casts with known NULL results.
       [not found] <bug-12277-3548@http.gcc.gnu.org/bugzilla/>
  2005-11-26  8:05 ` [Bug c++/12277] Warn " gdr at gcc dot gnu dot org
@ 2007-06-11 11:19 ` pinskia at gcc dot gnu dot org
  2009-07-06 20:45 ` jason at gcc dot gnu dot org
  2009-07-06 20:56 ` bangerth at gmail dot com
  3 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-06-11 11:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2007-06-11 11:18 -------
*** Bug 32282 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Woebbeking at web dot de


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12277] Warn on dynamic casts with known NULL results.
       [not found] <bug-12277-3548@http.gcc.gnu.org/bugzilla/>
@ 2005-11-26  8:05 ` gdr at gcc dot gnu dot org
  2007-06-11 11:19 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: gdr at gcc dot gnu dot org @ 2005-11-26  8:05 UTC (permalink / raw)
  To: gcc-bugs



-- 

gdr at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |gdr at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-09-10 19:11:30         |2005-11-26 08:05:53
               date|                            |


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12277] Warn on dynamic casts with known NULL results.
  2003-09-14 16:55 [Bug c++/12277] New: " 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; 14+ 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] 14+ messages in thread

* [Bug c++/12277] Warn on dynamic casts with known NULL results.
  2003-09-14 16:55 [Bug c++/12277] New: " 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; 14+ 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] 14+ messages in thread

* [Bug c++/12277] Warn on dynamic casts with known NULL results.
  2003-09-14 16:55 [Bug c++/12277] New: " 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; 14+ 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] 14+ messages in thread

* [Bug c++/12277] Warn on dynamic casts with known NULL results.
  2003-09-14 16:55 [Bug c++/12277] New: " 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; 14+ 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] 14+ messages in thread

end of thread, other threads:[~2021-10-01 10:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-12277-4@http.gcc.gnu.org/bugzilla/>
2013-11-07 10:26 ` [Bug c++/12277] Warn on dynamic casts with known NULL results paolo.carlini at oracle dot com
2014-11-27 21:21 ` gcc at dixie dot net.nz
2014-11-27 21:23 ` gcc at dixie dot net.nz
2014-11-28  8:44 ` ville.voutilainen at gmail dot com
2021-02-11 23:28 ` [Bug c++/12277] eliminate and warn " msebor at gcc dot gnu.org
2021-10-01 10:22 ` egallager at gcc dot gnu.org
     [not found] <bug-12277-3548@http.gcc.gnu.org/bugzilla/>
2005-11-26  8:05 ` [Bug c++/12277] Warn " gdr at gcc dot gnu dot org
2007-06-11 11:19 ` pinskia at gcc dot gnu dot org
2009-07-06 20:45 ` jason at gcc dot gnu dot org
2009-07-06 20:56 ` bangerth at gmail dot com
2003-09-14 16:55 [Bug c++/12277] New: " 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).