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
* [Bug c++/31449] [4.1/4.2/4.3 regression] static_cast can remove const-ness
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 ` reichelt at gcc dot gnu dot org
2007-04-09 17:31 ` mmitchel at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2007-04-03 23:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from reichelt at gcc dot gnu dot org 2007-04-04 00:06 -------
Confirmed.
The regression was introduced between GCC 4.0.2 and 4.0.3.
Mark, it looks like the following patch of yours is responsible for the
regression:
2006-01-21 Mark Mitchell <mark@codesourcery.com>
PR c++/25895
* class.c (build_base_path): Generate a NOP_EXPR instead of a
COMPONENT_REF if the base and derived classes are at the same
address.
--
reichelt at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mark at codesourcery dot
| |com, reichelt at gcc dot gnu
| |dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |accepts-invalid, monitored
Known to fail| |4.0.3
Known to work| |4.0.2
Last reconfirmed|0000-00-00 00:00:00 |2007-04-04 00:06:46
date| |
Summary|static_cast can remove |[4.1/4.2/4.3 regression]
|const-ness |static_cast can remove
| |const-ness
Target Milestone|--- |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31449
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/31449] [4.1/4.2/4.3 regression] static_cast can remove const-ness
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
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-04-09 17:31 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |mark at codesourcery dot com
|dot org |
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31449
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/31449] [4.1/4.2/4.3 regression] static_cast can remove const-ness
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
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-04-09 19:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from mmitchel at gcc dot gnu dot org 2007-04-09 20:46 -------
Subject: Bug 31449
Author: mmitchel
Date: Mon Apr 9 20:45:53 2007
New Revision: 123679
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123679
Log:
PR c++/31449
* class.c (build_base_path): Ensure that the converted pointer has
the same cv-qualification as the input.
PR c++/31449
* g++.dg/init/const5.C: New test.
Added:
trunk/gcc/testsuite/g++.dg/init/const5.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/class.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31449
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/31449] [4.1/4.2] static_cast can remove const-ness
2007-04-02 22:32 [Bug c++/31449] New: static_cast can remove const-ness simon_baldwin at yahoo dot com
` (2 preceding siblings ...)
2007-04-09 19:46 ` mmitchel at gcc dot gnu dot org
@ 2007-04-09 19:51 ` mmitchel at gcc dot gnu dot org
2007-04-10 3:01 ` [Bug c++/31449] [4.1] " mmitchel at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-04-09 19:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from mmitchel at gcc dot gnu dot org 2007-04-09 20:51 -------
Fixed in 4.3.0.
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.1/4.2/4.3 regression] |[4.1/4.2] static_cast can
|static_cast can remove |remove const-ness
|const-ness |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31449
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/31449] [4.1] static_cast can remove const-ness
2007-04-02 22:32 [Bug c++/31449] New: static_cast can remove const-ness simon_baldwin at yahoo dot com
` (3 preceding siblings ...)
2007-04-09 19:51 ` [Bug c++/31449] [4.1/4.2] " mmitchel at gcc dot gnu dot org
@ 2007-04-10 3:01 ` 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
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-04-10 3:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from mmitchel at gcc dot gnu dot org 2007-04-10 04:01 -------
Fixed in 4.2.0.
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.1/4.2] static_cast can |[4.1] static_cast can remove
|remove const-ness |const-ness
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31449
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/31449] [4.1/4.2] static_cast can remove const-ness
2007-04-02 22:32 [Bug c++/31449] New: static_cast can remove const-ness simon_baldwin at yahoo dot com
` (4 preceding siblings ...)
2007-04-10 3:01 ` [Bug c++/31449] [4.1] " mmitchel at gcc dot gnu dot org
@ 2007-04-10 3:01 ` 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
7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-04-10 3:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from mmitchel at gcc dot gnu dot org 2007-04-10 04:01 -------
Subject: Bug 31449
Author: mmitchel
Date: Tue Apr 10 04:01:08 2007
New Revision: 123690
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123690
Log:
PR c++/31449
* class.c (build_base_path): Ensure that the converted pointer has
the same cv-qualification as the input.
PR c++/31449
* g++.dg/init/const5.C: New test.
Added:
branches/gcc-4_2-branch/gcc/testsuite/g++.dg/init/const5.C
Modified:
branches/gcc-4_2-branch/gcc/cp/ChangeLog
branches/gcc-4_2-branch/gcc/cp/class.c
branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31449
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/31449] [4.1] static_cast can remove const-ness
2007-04-02 22:32 [Bug c++/31449] New: static_cast can remove const-ness simon_baldwin at yahoo dot com
` (5 preceding siblings ...)
2007-04-10 3:01 ` [Bug c++/31449] [4.1/4.2] " mmitchel at gcc dot gnu dot org
@ 2007-04-10 5:08 ` mmitchel at gcc dot gnu dot org
2007-04-10 5:08 ` mmitchel at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-04-10 5:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from mmitchel at gcc dot gnu dot org 2007-04-10 06:07 -------
Subject: Bug 31449
Author: mmitchel
Date: Tue Apr 10 06:07:41 2007
New Revision: 123691
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123691
Log:
PR c++/31449
* class.c (build_base_path): Ensure that the converted pointer has
the same cv-qualification as the input.
PR c++/31449
* g++.dg/init/const5.C: New test.
Added:
branches/gcc-4_1-branch/gcc/testsuite/g++.dg/init/const5.C
Modified:
branches/gcc-4_1-branch/gcc/cp/ChangeLog
branches/gcc-4_1-branch/gcc/cp/class.c
branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31449
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/31449] [4.1] static_cast can remove const-ness
2007-04-02 22:32 [Bug c++/31449] New: static_cast can remove const-ness simon_baldwin at yahoo dot com
` (6 preceding siblings ...)
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
7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-04-10 5:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from mmitchel at gcc dot gnu dot org 2007-04-10 06:07 -------
Fixed in 4.1.3.
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
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).