1 /* { dg-do compile } */
2 /* { dg-options "-O1 -fdump-tree-optimized" } */
3 
4 char *buffer1;
5 char *buffer2;
6 
7 #define SIZE 1000
8 
9 int
main(void)10 main (void)
11 {
12   const char* const foo1 = "hello world";
13 
14   /* MEMCHR.  */
15   if (__builtin_memchr ("", 'x', 1000)) /* Not folded away.  */
16     {
17       /* { dg-warning "reading 1000 bytes from a region of size 1" "" { target *-*-* } .-2 } */
18       __builtin_abort ();
19     }
20 
21   if (__builtin_memchr (foo1, 'x', 1000)) /* Not folded away.  */
22     {
23       /* { dg-warning "reading 1000 bytes from a region of size 1" "" { target *-*-* } .-2 } */
24       __builtin_abort ();
25     }
26 
27   /* STRNCMP.  */
28   if (strncmp ("a", "b", -1)) /* { dg-warning "implicit declaration of function" } */
29     __builtin_abort ();
30 
31   return 0;
32 }
33 
34 /* { dg-final { scan-tree-dump-times "__builtin_memchr" 2 "optimized" } } */
35