aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/constexpr-fold2.C
blob: 98aca2a2ce04f75fde50f35db3c21d7746e9c6cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// PR c++/65642
// { dg-do compile { target c++11 } }

#define SA(X) static_assert((X),#X)

constexpr char s[] = "abc";

constexpr bool
cmp (char const *a, char const *b)
{
  return a == b;
}

constexpr bool
fn1 (const char *s)
{
  return cmp (s, s + 1);
}

constexpr bool
fn2 (const char *s)
{
  return cmp (s + 1, s + 1);
}

constexpr auto c1 = fn1 (&s[0]);
constexpr auto c2 = fn2 (&s[0]);

SA (!c1);
SA (c2);