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
This commit is contained in:
Jason Merrill 2013-01-09 13:55:12 -05:00 committed by Jason Merrill
parent 9a002da86b
commit 96924e7e64
3 changed files with 22 additions and 0 deletions

View File

@ -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

View File

@ -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);

View File

@ -0,0 +1,12 @@
// PR c++/55893
// { dg-final { scan-assembler-not "rodata" } }
struct foo
{
virtual ~foo ();
};
int main ()
{
static const foo tmp;
}