PR c++/67550
* init.c (constant_value_1): Don't return a CONSTRUCTOR missing
non-constant elements.
From-SVN: r231777
2015-12-17 Jason Merrill <jason@redhat.com>
+ PR c++/67550
+ * init.c (constant_value_1): Don't return a CONSTRUCTOR missing
+ non-constant elements.
+
PR c++/67576
PR c++/25466
* rtti.c (build_typeid): Use save_expr, not stabilize_reference.
&& (TREE_CODE (init) == CONSTRUCTOR
|| TREE_CODE (init) == STRING_CST)))
break;
+ /* Don't return a CONSTRUCTOR for a variable with partial run-time
+ initialization, since it doesn't represent the entire value. */
+ if (TREE_CODE (init) == CONSTRUCTOR
+ && !DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))
+ break;
decl = unshare_expr (init);
}
return decl;
--- /dev/null
+// PR c++/67550
+// { dg-do run }
+
+struct S {
+ int x;
+ int y;
+};
+int foo() { return 1; }
+
+int main() {
+ S const data[] = {{0, foo()}};
+
+ S data2[] = {data[0]};
+
+ if (!data2[0].y)
+ __builtin_abort();
+}