+2011-08-30 Jason Merrill <jason@redhat.com>
+
+ PR c++/50234
+ * semantics.c (cxx_eval_component_reference): Handle
+ value-initialization for omitted initializers.
+
2011-08-29 Jason Merrill <jason@redhat.com>
PR c++/50224
if (field == part)
return value;
}
- if (TREE_CODE (TREE_TYPE (whole)) == UNION_TYPE)
+ if (TREE_CODE (TREE_TYPE (whole)) == UNION_TYPE
+ && CONSTRUCTOR_NELTS (whole) > 0)
{
/* DR 1188 says we don't have to deal with this. */
if (!allow_non_constant)
*non_constant_p = true;
return t;
}
- gcc_unreachable();
- return error_mark_node;
+
+ /* If there's no explicit init for this field, it's value-initialized. */
+ value = build_value_init (TREE_TYPE (t), tf_warning_or_error);
+ return cxx_eval_constant_expression (call, value,
+ allow_non_constant, addr,
+ non_constant_p);
}
/* Subroutine of cxx_eval_constant_expression.
--- /dev/null
+// PR c++/50234
+// { dg-options -std=c++0x }
+
+#define SA(X) static_assert((X),#X)
+
+struct A { int i; };
+
+constexpr int f(A a) { return a.i; }
+
+SA(f({}) == 0);