public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/31449]  New: static_cast can remove const-ness
@ 2007-04-02 22:32 simon_baldwin at yahoo dot com
  2007-04-03 23:07 ` [Bug c++/31449] [4.1/4.2/4.3 regression] " reichelt at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: simon_baldwin at yahoo dot com @ 2007-04-02 22:32 UTC (permalink / raw)
  To: gcc-bugs

The following const-incorrect program compiles without error on gcc 4.1.0, and
4.3.0 20070323:

class Foo {};
class Bar : public Foo {};
static const Foo *foo = 0;

static Bar *bar = static_cast<const Bar*>(foo);  // Error, casts away const

void func(const Foo *foo) {
  Bar *bar = static_cast<const Bar*>(foo);  // Error, casts away const
}

gcc 2.95.3, 3.4.5, and 4.0.2 report errors on the commented lines above, so it
looks like a compiler regression in 4.1.0.

I looked hard through existing PRs, and couldn't find this reported elsewhere
(the closest is PR 20475, but it's concerned with 3.4.4 and the const-ness, or
otherwise, of string literals, so not the same).  I'd be a little surprised if
I'm the first to see it, but it's possible...


-- 
           Summary: static_cast can remove const-ness
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: simon_baldwin at yahoo dot com


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


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

end of thread, other threads:[~2007-04-10  5:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-02 22:32 [Bug c++/31449] New: static_cast can remove const-ness simon_baldwin at yahoo dot com
2007-04-03 23:07 ` [Bug c++/31449] [4.1/4.2/4.3 regression] " reichelt at gcc dot gnu dot org
2007-04-09 17:31 ` mmitchel at gcc dot gnu dot org
2007-04-09 19:46 ` mmitchel at gcc dot gnu dot org
2007-04-09 19:51 ` [Bug c++/31449] [4.1/4.2] " mmitchel at gcc dot gnu dot org
2007-04-10  3:01 ` [Bug c++/31449] [4.1] " mmitchel at gcc dot gnu dot org
2007-04-10  3:01 ` [Bug c++/31449] [4.1/4.2] " mmitchel at gcc dot gnu dot org
2007-04-10  5:08 ` [Bug c++/31449] [4.1] " mmitchel at gcc dot gnu dot org
2007-04-10  5:08 ` mmitchel 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).