re PR c++/66635 (g++ ICE when compiling constexpr code with comma operator)
authorPaolo Carlini <paolo@gcc.gnu.org>
Wed, 1 Jun 2016 09:48:05 +0000 (09:48 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 1 Jun 2016 09:48:05 +0000 (09:48 +0000)
2016-06-01  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/66635
* g++.dg/cpp0x/constexpr-ice16.C: New.

From-SVN: r236978

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

index c806fdb2f54b42af40bb09a885f4374c38c8186a..c6e4a61cfa0e137ee4111f65200753f344256cba 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-01  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/66635
+       * g++.dg/cpp0x/constexpr-ice16.C: New.
+
 2016-06-01  Patrick Palka  <ppalka@gcc.gnu.org>
 
        PR tree-optimization/71314
@@ -11,9 +16,9 @@
 
 2016-05-31  Jan Hubicka  <hubicka@ucw.cz>
 
-       * g++.d/predict-lop-exit-1.C: Update template for new predictor name.
-       * g++.d/predict-lop-exit-2.C: Update template for new predictor name.
-       * g++.d/predict-lop-exit-2.C: Update template for new predictor name.
+       * g++.dg/predict-lop-exit-1.C: Update template for new predictor name.
+       * g++.dg/predict-lop-exit-2.C: Update template for new predictor name.
+       * g++.dg/predict-lop-exit-2.C: Update template for new predictor name.
 
 2016-05-31  Paolo Carlini  <paolo.carlini@oracle.com>
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice16.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice16.C
new file mode 100644 (file)
index 0000000..42b9226
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/66635
+// { dg-do compile { target c++11 } }
+
+#include <cassert>
+
+struct Foo {
+    constexpr Foo(const unsigned i) : val(i) {}
+    constexpr Foo operator-(const Foo &rhs) const {
+      return assert(val >= rhs.val), Foo(val - rhs.val); // { dg-error "call to non-constexpr" }
+    }
+    unsigned val;
+};
+
+constexpr Foo foo(Foo(1) - Foo(2));