[gcc]
[official-gcc.git] / gcc / testsuite / gcc.target / sh / pr64507.c
blobd3d93849bd3744271133166e1d9770369d4fc7fd
1 /* Check that the __builtin_strnlen returns 0 with with
2 non-constant 0 length. */
3 /* { dg-do run } */
4 /* { dg-options "-O2" } */
6 extern int snprintf(char *, int, const char *, ...);
7 extern void abort (void);
9 int main()
11 int i;
12 int cmp = 0;
13 char buffer[1024];
14 const char* s = "the string";
16 snprintf(buffer, 4, "%s", s);
18 for (i = 1; i < 4; i++)
19 cmp += __builtin_strncmp(buffer, s, i - 1);
21 if (cmp)
22 abort();
24 return 0;