Commit 024a6f45 by Paolo Carlini Committed by Jason Merrill

PR c++/82336 - link error with list-init default argument.

	* decl.c (check_default_argument): Unshare an initializer list.

Co-Authored-By: Jason Merrill <jason@redhat.com>

From-SVN: r258512
parent 17164de4
2018-03-13 Paolo Carlini <paolo.carlini@oracle.com>
Jason Merrill <jason@redhat.com>
PR c++/82336 - link error with list-init default argument.
* decl.c (check_default_argument): Unshare an initializer list.
2018-03-13 Jakub Jelinek <jakub@redhat.com>
PR c++/84843
......
......@@ -12668,7 +12668,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;
......
// 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(); }
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