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: unassig...@gcc.gnu.org ReportedBy: ppluzhni...@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.