Let tree_single_nonzero_warnv_p use range information
[official-gcc.git] / gcc / testsuite / gcc.dg / 20030711-1.c
blobe8691961f47505d8b111cb9560ea05a63af8b488
1 /* Test whether strncmp has not been "optimized" into memcmp
2 nor any code with memcmp semantics. */
3 /* { dg-do run { target mmap } } */
4 /* { dg-options "-O2" } */
5 #include <stddef.h>
6 #include <stdio.h>
7 #include <sys/mman.h>
8 #ifndef MAP_ANONYMOUS
9 #define MAP_ANONYMOUS MAP_ANON
10 #endif
11 #ifndef MAP_ANON
12 #define MAP_ANON 0
13 #endif
14 #ifndef MAP_FAILED
15 #define MAP_FAILED ((void *)-1)
16 #endif
17 #include <stdlib.h>
19 void __attribute__((noinline)) test (const char *p)
21 if (__builtin_strncmp (p, "abcdefghijklmnopq", 17) == 0)
22 abort ();
25 int main (void)
27 char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE,
28 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
29 if (p == MAP_FAILED)
30 return 0;
31 if (munmap (p + 65536, 65536) < 0)
32 return 0;
33 __builtin_memcpy (p + 65536 - 5, "abcd", 5);
34 test (p + 65536 - 5);
35 return 0;