commit f905470ca5ccda134972fdab07f7ed9a0380bf25
Author: Jason Merrill <jason@redhat.com>
Date: Tue Mar 13 19:34:54 2018 -0400
PR c++/82336 - link error with list-init default argument.
* decl.c (check_default_argument): Unshare an initializer list.
@@ -12661,7 +12661,9 @@ check_default_argument (tree decl, tree arg, tsubst_flags_t complain)
A default argument expression is implicitly converted to the
parameter type. */
++cp_unevaluated_operand;
- perform_implicit_conversion_flags (decl_type, arg, complain,
+ /* Avoid digest_init clobbering the initializer. */
+ tree carg = BRACE_ENCLOSED_INITIALIZER_P (arg) ? unshare_expr (arg): arg;
+ perform_implicit_conversion_flags (decl_type, carg, complain,
LOOKUP_IMPLICIT);
--cp_unevaluated_operand;
new file mode 100644
@@ -0,0 +1,8 @@
+// PR c++/82336
+// { dg-do link { target c++11 } }
+
+struct foo { int x = 5; };
+struct bar : foo { bar() = default; };
+struct baz { bar x; };
+void qux(baz = {}){}
+int main() { qux(); }