Commit b9d6b015 by Jason Merrill Committed by Jason Merrill

re PR c++/49355 (new T({""}) crashes G++ when struct T { std::string foobar };)

	PR c++/49355
	* tree.c (stabilize_init): Handle aggregate initialization.

From-SVN: r175736
parent 1ac93f10
2011-06-30 Jason Merrill <jason@redhat.com> 2011-06-30 Jason Merrill <jason@redhat.com>
PR c++/49355
* tree.c (stabilize_init): Handle aggregate initialization.
PR c++/48481 PR c++/48481
* name-lookup.c (struct arg_lookup): Add fn_set. * name-lookup.c (struct arg_lookup): Add fn_set.
(add_function): Check it. (add_function): Check it.
......
...@@ -3291,10 +3291,18 @@ stabilize_init (tree init, tree *initp) ...@@ -3291,10 +3291,18 @@ stabilize_init (tree init, tree *initp)
t = TARGET_EXPR_INITIAL (t); t = TARGET_EXPR_INITIAL (t);
if (TREE_CODE (t) == COMPOUND_EXPR) if (TREE_CODE (t) == COMPOUND_EXPR)
t = expr_last (t); t = expr_last (t);
if (TREE_CODE (t) == CONSTRUCTOR if (TREE_CODE (t) == CONSTRUCTOR)
&& EMPTY_CONSTRUCTOR_P (t)) {
/* Default-initialization. */ /* Aggregate initialization: stabilize each of the field
return true; initializers. */
unsigned i;
tree value;
bool good = true;
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (t), i, value)
if (!stabilize_init (value, initp))
good = false;
return good;
}
/* If the initializer is a COND_EXPR, we can't preevaluate /* If the initializer is a COND_EXPR, we can't preevaluate
anything. */ anything. */
......
2011-06-30 Jason Merrill <jason@redhat.com>
PR c++/49355
* g++.dg/cpp0x/initlist54.C: New.
2011-06-30 Martin Jambor <mjambor@suse.cz> 2011-06-30 Martin Jambor <mjambor@suse.cz>
* gcc.dg/tree-ssa/sra-12.c: New test. * gcc.dg/tree-ssa/sra-12.c: New test.
......
// PR c++/49355
// { dg-options -std=c++0x }
#include <string>
struct T {
std::string foobar;
};
int main()
{
T* x = new T({""});
}
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