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

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).