PR c++/88857 - ICE with value-initialization of argument in template.
authorMarek Polacek <polacek@redhat.com>
Thu, 28 Feb 2019 00:07:06 +0000 (00:07 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 28 Feb 2019 00:07:06 +0000 (00:07 +0000)
* 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
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist-value4.C [new file with mode: 0644]

index e4d876b..8ad0f22 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-27  Marek Polacek  <polacek@redhat.com>
+
+       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  <jason@redhat.com>
 
        PR c++/86969 - ICE with constexpr if and recursive generic lambdas.
index c53eb58..fb67d90 100644 (file)
@@ -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))
index eff4a81..0b126ba 100644 (file)
@@ -1,5 +1,10 @@
 2019-02-27  Marek Polacek  <polacek@redhat.com>
 
+       PR c++/88857 - ICE with value-initialization of argument in template.
+       * g++.dg/cpp0x/initlist-value4.C: New test.
+
+2019-02-27  Marek Polacek  <polacek@redhat.com>
+
        PR c++/89511 - ICE with using-declaration and unscoped enumerator.
        * g++.dg/cpp0x/using-enum-3.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-value4.C b/gcc/testsuite/g++.dg/cpp0x/initlist-value4.C
new file mode 100644 (file)
index 0000000..427147f
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/88857
+// { dg-do compile { target c++11 } }
+
+class S { int a; };
+void foo (const S &, int);
+
+template <int N>
+void
+bar ()
+{
+  foo ({}); // { dg-error "too few arguments to function" }
+}