gcc/testsuite/g++.dg/cpp0x/constexpr-fold2.C
raw| 1 | // PR c++/65642 |
| 2 | // { dg-do compile { target c++11 } } |
| 3 | |
| 4 | #define SA(X) static_assert((X),#X) |
| 5 | |
| 6 | constexpr char s[] = "abc"; |
| 7 | |
| 8 | constexpr bool |
| 9 | cmp (char const *a, char const *b) |
| 10 | { |
| 11 | return a == b; |
| 12 | } |
| 13 | |
| 14 | constexpr bool |
| 15 | fn1 (const char *s) |
| 16 | { |
| 17 | return cmp (s, s + 1); |
| 18 | } |
| 19 | |
| 20 | constexpr bool |
| 21 | fn2 (const char *s) |
| 22 | { |
| 23 | return cmp (s + 1, s + 1); |
| 24 | } |
| 25 | |
| 26 | constexpr auto c1 = fn1 (&s[0]); |
| 27 | constexpr auto c2 = fn2 (&s[0]); |
| 28 | |
| 29 | SA (!c1); |
| 30 | SA (c2); |