1 // { dg-do compile { target c++11 } }
2 
f1(const char * p,int q)3 constexpr const char *f1 (const char *p, int q) { return __builtin_strchr (p, q); }
f2(const char * p,int q)4 constexpr const char *f2 (const char *p, int q) { return __builtin_index (p, q); }
f3(const char * p,int q)5 constexpr const char *f3 (const char *p, int q) { return __builtin_strrchr (p, q); }
f4(const char * p,int q)6 constexpr const char *f4 (const char *p, int q) { return __builtin_rindex (p, q); }
7 constexpr const char a[] = "abcdefedcba";
8 static_assert (f1 ("abcde", 'f') == nullptr, "");
9 static_assert (f1 (a, 'g') == nullptr, "");
10 static_assert (f1 (a, 'f') == a + 5, "");
11 static_assert (f1 (a, 'c') == a + 2, "");
12 static_assert (f1 (a, '\0') == a + 11, "");
13 static_assert (f2 ("abcde", 'f') == nullptr, "");
14 static_assert (f2 (a, 'g') == nullptr, "");
15 static_assert (f2 (a, 'f') == a + 5, "");
16 static_assert (f2 (a, 'c') == a + 2, "");
17 static_assert (f2 (a, '\0') == a + 11, "");
18 static_assert (f3 ("abcde", 'f') == nullptr, "");
19 static_assert (f3 (a, 'g') == nullptr, "");
20 static_assert (f3 (a, 'f') == a + 5, "");
21 static_assert (f3 (a, 'c') == a + 8, "");
22 static_assert (f3 (a, '\0') == a + 11, "");
23 static_assert (f4 ("abcde", 'f') == nullptr, "");
24 static_assert (f4 (a, 'g') == nullptr, "");
25 static_assert (f4 (a, 'f') == a + 5, "");
26 static_assert (f4 (a, 'c') == a + 8, "");
27 static_assert (f4 (a, '\0') == a + 11, "");
28