Debian Codegraph @

gcc/testsuite/gcc.target/sh/pr64507.c

raw
1 /* Check that the __builtin_strnlen returns 0 with with
2 non-constant 0 length. */
3 /* { dg-do run } */
4 /* { dg-options "-O2" } */
5
6 extern int snprintf(char *, int, const char *, ...);
7 extern void abort (void);
8
9 int main()
10 {
11 int i;
12 int cmp = 0;
13 char buffer[1024];
14 const char* s = "the string";
15
16 snprintf(buffer, 4, "%s", s);
17
18 for (i = 1; i < 4; i++)
19 cmp += __builtin_strncmp(buffer, s, i - 1);
20
21 if (cmp)
22 abort();
23
24 return 0;
25 }