2010-08-19 Jason Merrill <jason@redhat.com>
+ PR c++/45315
+ * init.c (build_new_1): Don't use build_value_init in a template.
+ (build_value_init): Make sure we don't.
+
PR c++/45307
* cp-gimplify.c (cp_gimplify_expr): Also remove assignment
of empty class CONSTRUCTOR.
zero-initializing the object and then calling the default
constructor. */
+ /* The AGGR_INIT_EXPR tweaking below breaks in templates. */
+ gcc_assert (!processing_template_decl);
+
if (CLASS_TYPE_P (type))
{
if (type_has_user_provided_constructor (type))
{
init_expr = cp_build_indirect_ref (data_addr, RO_NULL, complain);
- if (TYPE_NEEDS_CONSTRUCTING (type) && !explicit_value_init_p)
+ if (TYPE_NEEDS_CONSTRUCTING (type)
+ && (!explicit_value_init_p || processing_template_decl))
{
init_expr = build_special_member_call (init_expr,
complete_ctor_identifier,
}
else if (explicit_value_init_p)
{
- /* Something like `new int()'. */
- tree val = build_value_init (type, complain);
- if (val == error_mark_node)
- return error_mark_node;
- init_expr = build2 (INIT_EXPR, type, init_expr, val);
+ if (processing_template_decl)
+ /* Don't worry about it, we'll handle this properly at
+ instantiation time. */;
+ else
+ {
+ /* Something like `new int()'. */
+ tree val = build_value_init (type, complain);
+ if (val == error_mark_node)
+ return error_mark_node;
+ init_expr = build2 (INIT_EXPR, type, init_expr, val);
+ }
}
else
{