This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54026] [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata
- From: "ppluzhnikov at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 19 Jul 2012 13:20:40 +0000
- Subject: [Bug c++/54026] [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata
- Auto-submitted: auto-generated
- References: <bug-54026-4@http.gcc.gnu.org/bugzilla/>
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-qualiïed expression shall not be modiïed (through
that expression), except that if it is of class type and has a mutable
component, that component can be modiïed (7.1.6.1).
7.1.6.1 The cv-qualiïers
...
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 modiïed