gcc/testsuite/g++.dg/cpp0x/constexpr-ice16.C
raw| 1 | // PR c++/66635 |
| 2 | // { dg-do compile { target c++11 } } |
| 3 | // { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } } |
| 4 | |
| 5 | #include <cassert> |
| 6 | |
| 7 | struct Foo { |
| 8 | constexpr Foo(const unsigned i) : val(i) {} |
| 9 | constexpr Foo operator-(const Foo &rhs) const { |
| 10 | return assert(val >= rhs.val), Foo(val - rhs.val); // { dg-error "call to non-.constexpr." } |
| 11 | } |
| 12 | unsigned val; |
| 13 | }; |
| 14 | |
| 15 | constexpr Foo foo(Foo(1) - Foo(2)); // { dg-message "in .constexpr. expansion of " } |