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: r195063
This commit is contained in:
Jason Merrill 2013-01-09 13:55:34 -05:00 committed by Jason Merrill
parent a81c7e2024
commit 168a6b6688
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-08 Joel Brobecker <brobecker@adacore.com>
* parser.c (cp_parser_initializer_list): Move declaration

View File

@ -6318,6 +6318,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;
}