Commit e7d61178 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/77375 (constant object with mutable subobject allocated in read-only memory)

	PR c++/77375
	* class.c (check_bases): Set CLASSTYPE_HAS_MUTABLE if any TYPE_HAS_MUTABLE_P
	for any bases.

	* g++.dg/cpp0x/mutable1.C: New test.

From-SVN: r240195
parent 146ec50f
2016-09-16 Jakub Jelinek <jakub@redhat.com>
PR c++/77375
* class.c (check_bases): Set CLASSTYPE_HAS_MUTABLE if any
TYPE_HAS_MUTABLE_P for any bases.
2016-09-16 Jason Merrill <jason@redhat.com>
* class.c (check_bases, set_one_vmethod_tm_attributes): Use
......
......@@ -1796,6 +1796,8 @@ check_bases (tree t,
SET_CLASSTYPE_REF_FIELDS_NEED_INIT
(t, CLASSTYPE_REF_FIELDS_NEED_INIT (t)
| CLASSTYPE_REF_FIELDS_NEED_INIT (basetype));
if (TYPE_HAS_MUTABLE_P (basetype))
CLASSTYPE_HAS_MUTABLE (t) = 1;
/* A standard-layout class is a class that:
...
......
2016-09-16 Jakub Jelinek <jakub@redhat.com>
PR c++/77375
* g++.dg/cpp0x/mutable1.C: New test.
2016-09-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77612
......
// PR c++/77375
// { dg-do run { target c++11 } }
struct Base { mutable int i; };
struct Derived : Base {};
const Derived foo{};
int
main ()
{
foo.i = 42;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment