public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23418] New: old-style cast uses reinterpret+const instead of static+const
@ 2005-08-16 10:18 stephan dot bergmann at sun dot com
  2005-08-16 10:44 ` [Bug c++/23418] " caolanm at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: stephan dot bergmann at sun dot com @ 2005-08-16 10:18 UTC (permalink / raw)
  To: gcc-bugs

In the program

  #include <stdio.h>
  struct Base1 { int x1; };
  struct Base2 { int x2; };
  struct Derived: public Base1, public Base2 {};
  int main() {
    Derived const * d = new Derived;
    printf("%p %p %p\n", d, (Base2 *) d, (Base2 const *) d);
  }

the cast "(Base2 *) d" effectively does a

  const_cast< Base2 * >(reinterpret_cast< Base2 const * >(d))

instead of a

  const_cast< Base2 * >(static_cast< Base2 const * >(d))

(with the effect that of the three printed pointer values, errouneously the
first two are identical instead of the last two).  This is in violation of 5.4/5
of the C++ Standard.

This happens with both 4.0.0 and 4.0.1, but not with 3.4.3.  This error affects
the OpenOffice.org code base.

-- 
           Summary: old-style cast uses reinterpret+const instead of
                    static+const
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: stephan dot bergmann at sun dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c++/23418] old-style cast uses reinterpret+const instead of static+const
  2005-08-16 10:18 [Bug c++/23418] New: old-style cast uses reinterpret+const instead of static+const stephan dot bergmann at sun dot com
@ 2005-08-16 10:44 ` caolanm at redhat dot com
  2005-08-16 10:55 ` caolanm at redhat dot com
  2005-08-16 11:57 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: caolanm at redhat dot com @ 2005-08-16 10:44 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |caolanm at redhat dot com


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


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

* [Bug c++/23418] old-style cast uses reinterpret+const instead of static+const
  2005-08-16 10:18 [Bug c++/23418] New: old-style cast uses reinterpret+const instead of static+const stephan dot bergmann at sun dot com
  2005-08-16 10:44 ` [Bug c++/23418] " caolanm at redhat dot com
@ 2005-08-16 10:55 ` caolanm at redhat dot com
  2005-08-16 11:57 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: caolanm at redhat dot com @ 2005-08-16 10:55 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at redhat dot com


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


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

* [Bug c++/23418] old-style cast uses reinterpret+const instead of static+const
  2005-08-16 10:18 [Bug c++/23418] New: old-style cast uses reinterpret+const instead of static+const stephan dot bergmann at sun dot com
  2005-08-16 10:44 ` [Bug c++/23418] " caolanm at redhat dot com
  2005-08-16 10:55 ` caolanm at redhat dot com
@ 2005-08-16 11:57 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-16 11:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-16 11:56 -------
This has already been fixed in 4.0.2.
This is a dup of bug 22132.

*** This bug has been marked as a duplicate of 22132 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2005-08-16 11:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-16 10:18 [Bug c++/23418] New: old-style cast uses reinterpret+const instead of static+const stephan dot bergmann at sun dot com
2005-08-16 10:44 ` [Bug c++/23418] " caolanm at redhat dot com
2005-08-16 10:55 ` caolanm at redhat dot com
2005-08-16 11:57 ` 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).