From 294a3e20e5bf4290cf9001d1a532a155af3bca9c Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 28 Feb 2019 00:07:06 +0000 Subject: [PATCH] PR c++/88857 - ICE with value-initialization of argument in template. * call.c (convert_like_real): Don't call build_value_init in template. * g++.dg/cpp0x/initlist-value4.C: New test. From-SVN: r269267 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/call.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/initlist-value4.C | 12 ++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-value4.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e4d876b4c0b..8ad0f221efc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-02-27 Marek Polacek + + PR c++/88857 - ICE with value-initialization of argument in template. + * call.c (convert_like_real): Don't call build_value_init in template. + 2019-02-27 Jason Merrill PR c++/86969 - ICE with constexpr if and recursive generic lambdas. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index c53eb582aac..fb67d905acd 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7005,7 +7005,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, /* If we're initializing from {}, it's value-initialization. */ if (BRACE_ENCLOSED_INITIALIZER_P (expr) && CONSTRUCTOR_NELTS (expr) == 0 - && TYPE_HAS_DEFAULT_CONSTRUCTOR (totype)) + && TYPE_HAS_DEFAULT_CONSTRUCTOR (totype) + && !processing_template_decl) { bool direct = CONSTRUCTOR_IS_DIRECT_INIT (expr); if (abstract_virtuals_error_sfinae (NULL_TREE, totype, complain)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eff4a81d28b..0b126baf7b2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-27 Marek Polacek + + PR c++/88857 - ICE with value-initialization of argument in template. + * g++.dg/cpp0x/initlist-value4.C: New test. + 2019-02-27 Marek Polacek PR c++/89511 - ICE with using-declaration and unscoped enumerator. diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-value4.C b/gcc/testsuite/g++.dg/cpp0x/initlist-value4.C new file mode 100644 index 00000000000..427147ff7f2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-value4.C @@ -0,0 +1,12 @@ +// PR c++/88857 +// { dg-do compile { target c++11 } } + +class S { int a; }; +void foo (const S &, int); + +template +void +bar () +{ + foo ({}); // { dg-error "too few arguments to function" } +} -- 2.30.2