re PR c++/86926 (ICE for a recursive generic lambda)
authorMarek Polacek <polacek@redhat.com>
Fri, 18 Jan 2019 16:42:57 +0000 (16:42 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 18 Jan 2019 16:42:57 +0000 (16:42 +0000)
PR c++/86926
* g++.dg/cpp1z/constexpr-lambda23.C: New test.

From-SVN: r268080

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/constexpr-lambda23.C [new file with mode: 0644]

index 19f5b21..28b74d5 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-18  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/86926
+       * g++.dg/cpp1z/constexpr-lambda23.C: New test.
+
 2019-01-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR middle-end/88587
diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda23.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda23.C
new file mode 100644 (file)
index 0000000..4ff866b
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/86926
+// { dg-do compile { target c++17 } }
+
+int
+main()
+{
+    constexpr auto f = [](auto self, auto n) {
+        if(n < 2)
+         return n;
+        return self(self, n - 1) + self(self, n - 2);
+    };
+
+    constexpr auto fibonacci = [=](auto n) { return f(f, n); };
+
+    static_assert(fibonacci(7) == 13);
+}