libstdc++: Qualify calls in <bits/stl_uninitialized.h> to prevent ADL
[official-gcc.git] / gcc / testsuite / gcc.dg / pr79214.c
blob2f93eed2789de3cb5c19b2dc9775fc16dc56cee6
1 /* PR preprocessor/79214 - -Wno-system-header defeats strncat buffer overflow
2 warnings
3 { dg-do compile }
4 { dg-options "-O2" } */
6 #include "pr79214.h"
8 typedef __SIZE_TYPE__ size_t;
10 char d[3];
11 char s[4];
13 static size_t range (void)
15 extern size_t size ();
16 size_t n = size ();
17 if (n <= sizeof d)
18 return sizeof d + 1;
20 return n;
23 void test_bzero (void)
25 bzero (d, range ()); /* { dg-warning ".__builtin_(bzero|memset). writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
28 void test_memcpy (void)
30 memcpy (d, s, range ()); /* { dg-warning ".__builtin_memcpy. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
33 void test_memmove (void)
35 memmove (d, d + 1, range ()); /* { dg-warning ".__builtin_memmove. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
38 void test_mempcpy (void)
40 mempcpy (d, s, range ()); /* { dg-warning ".__builtin_mempcpy. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
43 void test_memset (int n)
45 memset (d, n, range ()); /* { dg-warning ".__builtin_memset. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
48 void test_strcat (int i)
50 const char *s = i < 0 ? "123" : "4567";
52 strcat (d, s); /* { dg-warning ".__builtin_strcat. writing between 4 and 5 bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
55 char* test_stpcpy (int i)
57 const char *s = i < 0 ? "123" : "4567";
59 return stpcpy (d, s); /* { dg-warning ".__builtin_stpcpy. writing between 4 and 5 bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
62 char* test_stpncpy (int i)
64 const char *s = i < 0 ? "123" : "4567";
66 return stpncpy (d, s, range ()); /* { dg-warning ".__builtin_stpncpy. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
69 char* test_strcpy (int i)
71 const char *s = i < 0 ? "123" : "4567";
73 return strcpy (d, s); /* { dg-warning ".__builtin_strcpy. writing between 4 and 5 bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
76 char* test_strncpy (int i)
78 const char *s = i < 0 ? "123" : "4567";
80 return strncpy (d, s, range ()); /* { dg-warning ".__builtin_strncpy. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
83 char* test_strncat (int i)
85 const char *s = i < 0 ? "123" : "4567";
87 return strncat (d, s, range ()); /* { dg-warning ".__builtin_strncat. specified bound \\\[4, \[0-9\]+] exceeds destination size 3" "pr?????" { xfail { *-*-* } } } */