public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54026] New: [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata
@ 2012-07-19 4:09 ppluzhnikov at google dot com
2012-07-19 10:08 ` [Bug c++/54026] " rguenth at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: ppluzhnikov at google dot com @ 2012-07-19 4:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54026
Bug #: 54026
Summary: [4.7/4.8 regression] template const struct with
mutable members erroneously emitted to .rodata
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ppluzhnikov@google.com
Reproduced with 4.7 and current trunk:
g++ (GCC) 4.8.0 20120719 (experimental)
// --- cut here ---
void non_const(int *);
template <typename T>
struct Foo {
T x;
mutable int y;
void func() const { non_const(&y); }
};
struct Bar {
int x;
mutable int y;
void func() const { non_const(&y); }
};
const Foo<int> foo = { 1, 2 };
const Bar bar = { 3, 4 };
// --- cut here ---
Results in:
.data
.align 4
.type _ZL3bar, @object
.size _ZL3bar, 8
_ZL3bar:
.long 3
.long 4
.section .rodata
.align 4
.type _ZL3foo, @object
.size _ZL3foo, 8
_ZL3foo:
.long 1
.long 2
But it is a bug to place "foo" into .rodata, since it contains a mutable
member.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/54026] [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata
2012-07-19 4:09 [Bug c++/54026] New: [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata ppluzhnikov at google dot com
@ 2012-07-19 10:08 ` rguenth at gcc dot gnu.org
2012-07-19 13:20 ` ppluzhnikov at google dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-19 10:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54026
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-19 10:08:08 UTC ---
I don't think 'mutable' overrides a const declaration specifier.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/54026] [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata
2012-07-19 4:09 [Bug c++/54026] New: [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata ppluzhnikov at google dot com
2012-07-19 10:08 ` [Bug c++/54026] " rguenth at gcc dot gnu.org
@ 2012-07-19 13:20 ` ppluzhnikov at google dot com
2012-07-19 14:46 ` hjl.tools at gmail dot com
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ppluzhnikov at google dot com @ 2012-07-19 13:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54026
--- Comment #2 from Paul Pluzhnikov <ppluzhnikov at google dot com> 2012-07-19 13:20:40 UTC ---
(In reply to comment #1)
> I don't think 'mutable' overrides a const declaration specifier.
I am not a language lawyer, but I believe the standard disagrees: from
INCITS+ISO+IEC+14882-2011-DRAFT.pdf (similar language in
INCITS+ISO+IEC+14882-1998.pdf):
3.10 Lvalues and rvalues
...
8 The referent of a const-qualified expression shall not be modified (through
that expression), except that if it is of class type and has a mutable
component, that component can be modified (7.1.6.1).
7.1.6.1 The cv-qualifiers
...
5 For another example
struct X {
mutable int i;
int j;
};
struct Y {
X x;
Y();
};
const Y y;
y.x.i++; // well-formed: mutable member can be modified
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/54026] [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata
2012-07-19 4:09 [Bug c++/54026] New: [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata ppluzhnikov at google dot com
2012-07-19 10:08 ` [Bug c++/54026] " rguenth at gcc dot gnu.org
2012-07-19 13:20 ` ppluzhnikov at google dot com
@ 2012-07-19 14:46 ` hjl.tools at gmail dot com
2012-07-19 14:53 ` hjl.tools at gmail dot com
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2012-07-19 14:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54026
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at redhat dot com
--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> 2012-07-19 14:46:02 UTC ---
It is caused by revision 176052:
http://gcc.gnu.org/ml/gcc-cvs/2011-07/msg00317.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/54026] [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata
2012-07-19 4:09 [Bug c++/54026] New: [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata ppluzhnikov at google dot com
` (2 preceding siblings ...)
2012-07-19 14:46 ` hjl.tools at gmail dot com
@ 2012-07-19 14:53 ` hjl.tools at gmail dot com
2012-07-19 16:44 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2012-07-19 14:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54026
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-07-19
Version|unknown |4.8.0
Target Milestone|--- |4.7.2
Ever Confirmed|0 |1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/54026] [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata
2012-07-19 4:09 [Bug c++/54026] New: [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata ppluzhnikov at google dot com
` (3 preceding siblings ...)
2012-07-19 14:53 ` hjl.tools at gmail dot com
@ 2012-07-19 16:44 ` jakub at gcc dot gnu.org
2012-07-20 6:29 ` jason at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-07-19 16:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54026
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-07-19 16:44:20 UTC ---
The problem is that for incomplete types TYPE_HAS_MUTABLE_P is never going to
be true, as finish_struct_1 hasn't been called yet, therefore not
check_bases_and_members and check_field_decls which sets CLASSTYPE_HAS_MUTABLE.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/54026] [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata
2012-07-19 4:09 [Bug c++/54026] New: [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata ppluzhnikov at google dot com
` (4 preceding siblings ...)
2012-07-19 16:44 ` jakub at gcc dot gnu.org
@ 2012-07-20 6:29 ` jason at gcc dot gnu.org
2012-07-20 6:29 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2012-07-20 6:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54026
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |jason at gcc dot gnu.org
Resolution| |FIXED
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-20 06:28:53 UTC ---
Checking in fix now.
--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-20 06:29:19 UTC ---
Author: jason
Date: Fri Jul 20 06:29:13 2012
New Revision: 189701
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189701
Log:
PR c++/54026
* typeck.c (cp_apply_type_quals_to_decl): Check COMPLETE_TYPE_P.
Added:
trunk/gcc/testsuite/g++.dg/init/mutable1.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/typeck.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/54026] [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata
2012-07-19 4:09 [Bug c++/54026] New: [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata ppluzhnikov at google dot com
` (5 preceding siblings ...)
2012-07-20 6:29 ` jason at gcc dot gnu.org
@ 2012-07-20 6:29 ` jason at gcc dot gnu.org
2012-07-20 6:30 ` jason at gcc dot gnu.org
2012-07-20 6:30 ` jason at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2012-07-20 6:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54026
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |jason at gcc dot gnu.org
Resolution| |FIXED
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-20 06:28:53 UTC ---
Checking in fix now.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/54026] [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata
2012-07-19 4:09 [Bug c++/54026] New: [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata ppluzhnikov at google dot com
` (6 preceding siblings ...)
2012-07-20 6:29 ` jason at gcc dot gnu.org
@ 2012-07-20 6:30 ` jason at gcc dot gnu.org
2012-07-20 6:30 ` jason at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2012-07-20 6:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54026
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |jason at gcc dot gnu.org
Resolution| |FIXED
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-20 06:28:53 UTC ---
Checking in fix now.
--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-20 06:29:19 UTC ---
Author: jason
Date: Fri Jul 20 06:29:13 2012
New Revision: 189701
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189701
Log:
PR c++/54026
* typeck.c (cp_apply_type_quals_to_decl): Check COMPLETE_TYPE_P.
Added:
trunk/gcc/testsuite/g++.dg/init/mutable1.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/typeck.c
trunk/gcc/testsuite/ChangeLog
--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-20 06:29:37 UTC ---
Author: jason
Date: Fri Jul 20 06:29:33 2012
New Revision: 189702
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189702
Log:
PR c++/54026
* typeck.c (cp_apply_type_quals_to_decl): Check COMPLETE_TYPE_P.
Added:
branches/gcc-4_7-branch/gcc/testsuite/g++.dg/init/mutable1.C
Modified:
branches/gcc-4_7-branch/gcc/cp/ChangeLog
branches/gcc-4_7-branch/gcc/cp/typeck.c
branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/54026] [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata
2012-07-19 4:09 [Bug c++/54026] New: [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata ppluzhnikov at google dot com
` (7 preceding siblings ...)
2012-07-20 6:30 ` jason at gcc dot gnu.org
@ 2012-07-20 6:30 ` jason at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2012-07-20 6:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54026
--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-20 06:29:37 UTC ---
Author: jason
Date: Fri Jul 20 06:29:33 2012
New Revision: 189702
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189702
Log:
PR c++/54026
* typeck.c (cp_apply_type_quals_to_decl): Check COMPLETE_TYPE_P.
Added:
branches/gcc-4_7-branch/gcc/testsuite/g++.dg/init/mutable1.C
Modified:
branches/gcc-4_7-branch/gcc/cp/ChangeLog
branches/gcc-4_7-branch/gcc/cp/typeck.c
branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-07-20 6:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-19 4:09 [Bug c++/54026] New: [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata ppluzhnikov at google dot com
2012-07-19 10:08 ` [Bug c++/54026] " rguenth at gcc dot gnu.org
2012-07-19 13:20 ` ppluzhnikov at google dot com
2012-07-19 14:46 ` hjl.tools at gmail dot com
2012-07-19 14:53 ` hjl.tools at gmail dot com
2012-07-19 16:44 ` jakub at gcc dot gnu.org
2012-07-20 6:29 ` jason at gcc dot gnu.org
2012-07-20 6:29 ` jason at gcc dot gnu.org
2012-07-20 6:30 ` jason at gcc dot gnu.org
2012-07-20 6:30 ` jason at gcc dot gnu.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).