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 e4d876b4c0bad9911a3e27283cb292ee529ff100..8ad0f221efc0293c3bf6dff6d6dc3d34fdd9227f 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 c53eb582aac9a3509f1f4296d82e3dc35e5e8899..fb67d905acdfcda0a1f5f0474035a51b2b714f29 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 eff4a81d28bbd68870e9ce4f9180230e2d8a8c98..0b126baf7b26a230fc03cc03d2e506a9050d8c6b 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.
+       * 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.
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" }
+}