This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/54026] [4.7/4.8 regression] template const struct with mutable members erroneously emitted to .rodata


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]