public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/38557]  New: dynamic_cast should give a warning/error for non related classes
@ 2008-12-17 17:13 Woebbeking at web dot de
  2008-12-17 23:27 ` [Bug c++/38557] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Woebbeking at web dot de @ 2008-12-17 17:13 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 696 bytes --]

Hi,

in this example

struct A
{
    virtual ~A() {}
};


struct B
{
    virtual ~B() {}
};


int main()
{
    A* a(0);

    dynamic_cast<B*>(a);
    static_cast<B*>(a);

    return 0;
}

the static_cast gives an error but the dynamic_cast not even a warning.


Cheers,
André


-- 
           Summary: dynamic_cast should give a warning/error for non related
                    classes
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Woebbeking at web dot de


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


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

* [Bug c++/38557] dynamic_cast should give a warning/error for non related classes
  2008-12-17 17:13 [Bug c++/38557] New: dynamic_cast should give a warning/error for non related classes Woebbeking at web dot de
@ 2008-12-17 23:27 ` pinskia at gcc dot gnu dot org
  2009-01-30 16:02 ` bangerth at gmail dot com
  2009-03-07 20:02 ` fang at csl dot cornell dot edu
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-17 23:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-12-17 23:25 -------
I think this is basically the same as PR 12277.


-- 


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


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

* [Bug c++/38557] dynamic_cast should give a warning/error for non related classes
  2008-12-17 17:13 [Bug c++/38557] New: dynamic_cast should give a warning/error for non related classes Woebbeking at web dot de
  2008-12-17 23:27 ` [Bug c++/38557] " pinskia at gcc dot gnu dot org
@ 2009-01-30 16:02 ` bangerth at gmail dot com
  2009-03-07 20:02 ` fang at csl dot cornell dot edu
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at gmail dot com @ 2009-01-30 16:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from bangerth at gmail dot com  2009-01-30 16:02 -------
Confirmed. Gcc would have to keep track of the actual types of variables.
W.


-- 

bangerth at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at gmail dot com
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-01-30 16:02:26
               date|                            |


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


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

* [Bug c++/38557] dynamic_cast should give a warning/error for non related classes
  2008-12-17 17:13 [Bug c++/38557] New: dynamic_cast should give a warning/error for non related classes Woebbeking at web dot de
  2008-12-17 23:27 ` [Bug c++/38557] " pinskia at gcc dot gnu dot org
  2009-01-30 16:02 ` bangerth at gmail dot com
@ 2009-03-07 20:02 ` fang at csl dot cornell dot edu
  2 siblings, 0 replies; 4+ messages in thread
From: fang at csl dot cornell dot edu @ 2009-03-07 20:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from fang at csl dot cornell dot edu  2009-03-07 20:02 -------
If class C inherits from A and B, would we conservatively consider possible
cross-casts from A* to B* through C*, when trying to statically analyze the
dynamic_cast?  (And would it matter if class C wasn't even visible to this
translation unit?)


-- 

fang at csl dot cornell dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fang at csl dot cornell dot
                   |                            |edu


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


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

end of thread, other threads:[~2009-03-07 20:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-17 17:13 [Bug c++/38557] New: dynamic_cast should give a warning/error for non related classes Woebbeking at web dot de
2008-12-17 23:27 ` [Bug c++/38557] " pinskia at gcc dot gnu dot org
2009-01-30 16:02 ` bangerth at gmail dot com
2009-03-07 20:02 ` fang at csl dot cornell dot edu

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