aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/sh/pr64507.c
blob: d3d93849bd3744271133166e1d9770369d4fc7fd (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
/* Check that the __builtin_strnlen returns 0 with with 
   non-constant 0 length.  */
/* { dg-do run } */
/* { dg-options "-O2" } */

extern int snprintf(char *, int, const char *, ...);
extern void abort (void);

int main()
 {
   int i;
   int cmp = 0;
   char buffer[1024];
   const char* s = "the string";

   snprintf(buffer, 4, "%s", s);

   for (i = 1; i < 4; i++)
     cmp += __builtin_strncmp(buffer, s, i - 1);

  if (cmp)
    abort();

  return 0;
}