145
|
1 // PR c++/80265
|
|
2 // { dg-do compile { target c++14 } }
|
|
3
|
|
4 constexpr bool compare() {
|
|
5 char s1[] = "foo";
|
|
6 char s2[] = "fxo";
|
|
7 if (!__builtin_memcmp(s1, s2, 3))
|
|
8 return false;
|
|
9 s2[1] = 'o';
|
|
10 if (__builtin_memcmp(s1, s2, 3))
|
|
11 return false;
|
|
12 if (__builtin_strcmp(s1, s2))
|
|
13 return false;
|
|
14 return true;
|
|
15 }
|
|
16
|
|
17 constexpr bool length() {
|
|
18 char s[] = "foo";
|
|
19 if (__builtin_strlen(s) != 3)
|
|
20 return false;
|
|
21 return true;
|
|
22 }
|
|
23
|
|
24 constexpr bool find() {
|
|
25 char s[] = "foo";
|
|
26 if (__builtin_memchr(s, 'f', 3) != s)
|
|
27 return false;
|
|
28 if (__builtin_strchr(s, 'o') != s+1)
|
|
29 return false;
|
|
30 if (__builtin_strstr(s, "oo") != s+1)
|
|
31 return false;
|
|
32 return true;
|
|
33 }
|
|
34
|
|
35 static_assert( compare(), "" );
|
|
36 static_assert( length(), "" );
|
|
37 static_assert( find(), "" );
|