aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-01-09 13:55:12 -0500
committerJason Merrill <jason@gcc.gnu.org>2013-01-09 13:55:12 -0500
commit96924e7e64db44da01b320f6cbe6cbb8676ee1ef (patch)
tree2af120e71646f698e080a46de40bb0f19d575dd1 /gcc
parent9a002da86b6a69292b2d520a17cf1412e092ec76 (diff)
downloadgcc-96924e7e64db44da01b320f6cbe6cbb8676ee1ef.zip
gcc-96924e7e64db44da01b320f6cbe6cbb8676ee1ef.tar.gz
gcc-96924e7e64db44da01b320f6cbe6cbb8676ee1ef.tar.bz2
re PR c++/55893 ([C++11] runtime segfault with static const object with virtual destructor)
PR c++/55893 * decl.c (cp_finish_decl): Clear TREE_READONLY if the variable needs destruction. From-SVN: r195062
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c4
-rw-r--r--gcc/testsuite/g++.dg/init/const9.C12
3 files changed, 22 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d67a3c4..fe64da5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2013-01-09 Jason Merrill <jason@redhat.com>
+
+ PR c++/55893
+ * decl.c (cp_finish_decl): Clear TREE_READONLY if the variable
+ needs destruction.
+
2013-01-09 Jakub Jelinek <jakub@redhat.com>
PR c/48418
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 9640824..c3622ec 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6417,6 +6417,10 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
}
else if (was_readonly)
TREE_READONLY (decl) = 1;
+
+ /* Likewise if it needs destruction. */
+ if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
+ TREE_READONLY (decl) = 0;
}
make_rtl_for_nonlocal_decl (decl, init, asmspec);
diff --git a/gcc/testsuite/g++.dg/init/const9.C b/gcc/testsuite/g++.dg/init/const9.C
new file mode 100644
index 0000000..ba1dfd4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/const9.C
@@ -0,0 +1,12 @@
+// PR c++/55893
+// { dg-final { scan-assembler-not "rodata" } }
+
+struct foo
+{
+ virtual ~foo ();
+};
+
+int main ()
+{
+ static const foo tmp;
+}