Update ChangeLog and version files for release
[official-gcc.git] / gcc / testsuite / g++.dg / torture / Wsizeof-pointer-memaccess1.C
blob8b5c33e24b3d7f6072df418bf7b58133dd16f049
1 // Test -Wsizeof-pointer-memaccess warnings.
2 // { dg-do compile }
3 // { dg-options "-Wall -Wno-sizeof-array-argument" }
4 // Test just twice, once with -O0 non-fortified, once with -O2 fortified.
5 // { dg-skip-if "" { *-*-* }  { "*" } { "-O0" "-O2" } }
6 // { dg-skip-if "" { *-*-* }  { "-flto" } { "" } }
8 extern "C" {
10 typedef __SIZE_TYPE__ size_t;
11 extern void *memset (void *, int, size_t);
12 extern void *memcpy (void *__restrict, const void *__restrict, size_t);
13 extern void *memmove (void *__restrict, const void *__restrict, size_t);
14 extern int memcmp (const void *, const void *, size_t);
15 extern char *strncpy (char *__restrict, const char *__restrict, size_t);
16 extern char *strncat (char *__restrict, const char *__restrict, size_t);
17 extern char *stpncpy (char *__restrict, const char *__restrict, size_t);
18 extern char *strndup (const char *, size_t);
19 extern int strncmp (const char *, const char *, size_t);
20 extern int strncasecmp (const char *, const char *, size_t);
22 #ifdef __OPTIMIZE__
23 # define bos(ptr) __builtin_object_size (ptr, 1)
24 # define bos0(ptr) __builtin_object_size (ptr, 0)
26 __attribute__((__always_inline__, __gnu_inline__, __artificial__))
27 extern inline void *
28 memset (void *dest, int c, size_t len)
30   return __builtin___memset_chk (dest, c, len, bos0 (dest));
33 __attribute__((__always_inline__, __gnu_inline__, __artificial__))
34 extern inline void *
35 memcpy (void *__restrict dest, const void *__restrict src, size_t len)
37   return __builtin___memcpy_chk (dest, src, len, bos0 (dest));
40 __attribute__((__always_inline__, __gnu_inline__, __artificial__))
41 extern inline void *
42 memmove (void *dest, const void *src, size_t len)
44   return __builtin___memmove_chk (dest, src, len, bos0 (dest));
47 __attribute__((__always_inline__, __gnu_inline__, __artificial__))
48 extern inline char *
49 strncpy (char *__restrict dest, const char *__restrict src, size_t len)
51   return __builtin___strncpy_chk (dest, src, len, bos (dest));
54 __attribute__((__always_inline__, __gnu_inline__, __artificial__))
55 extern inline char *
56 strncat (char *dest, const char *src, size_t len)
58   return __builtin___strncat_chk (dest, src, len, bos (dest));
61 __attribute__((__always_inline__, __gnu_inline__, __artificial__))
62 extern inline char *
63 stpncpy (char *__restrict dest, const char *__restrict src, size_t len)
65   return __builtin___stpncpy_chk (dest, src, len, bos (dest));
67 #endif
71 struct A { short a, b; int c, d; long e, f; };
72 typedef struct A TA;
73 typedef struct A *PA;
74 typedef TA *PTA;
75 struct B {};
76 typedef struct B TB;
77 typedef struct B *PB;
78 typedef TB *PTB;
79 typedef int X[3][3][3];
81 int
82 f1 (void *x, int z)
84   struct A a, *pa1 = &a;
85   TA *pa2 = &a;
86   PA pa3 = &a;
87   PTA pa4 = &a;
88   memset (&a, 0, sizeof (&a));              // { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" }
89   memset (pa1, 0, sizeof (pa1));            // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
90   memset (pa2, 0, sizeof pa2);              // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
91   memset (pa3, 0, sizeof (pa3));            // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
92   memset (pa4, 0, sizeof pa4);              // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
93   memset (pa1, 0, sizeof (struct A *));     // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
94   memset (pa2, 0, sizeof (PTA));            // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
95   memset (pa3, 0, sizeof (PA));             // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
96   memset (pa4, 0, sizeof (__typeof (pa4))); // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
98   memcpy (&a, x, sizeof (&a));              // { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" }
99   memcpy (pa1, x, sizeof (pa1));            // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
100   memcpy (pa2, x, sizeof pa2);              // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
101   memcpy (pa3, x, sizeof (pa3));            // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
102   memcpy (pa4, x, sizeof pa4);              // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
103   memcpy (pa1, x, sizeof (struct A *));     // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
104   memcpy (pa2, x, sizeof (PTA));            // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
105   memcpy (pa3, x, sizeof (PA));             // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
106   memcpy (pa4, x, sizeof (__typeof (pa4))); // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
108   memcpy (x, &a, sizeof (&a));              // { dg-warning "call is the same expression as the source; did you mean to remove the addressof" }
109   memcpy (x, pa1, sizeof (pa1));            // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
110   memcpy (x, pa2, sizeof pa2);              // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
111   memcpy (x, pa3, sizeof (pa3));            // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
112   memcpy (x, pa4, sizeof pa4);              // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
113   memcpy (x, pa1, sizeof (struct A *));     // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
114   memcpy (x, pa2, sizeof (PTA));            // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
115   memcpy (x, pa3, sizeof (PA));             // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
116   memcpy (x, pa4, sizeof (__typeof (pa4))); // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
118   memmove (&a, x, sizeof (&a));             // { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" }
119   memmove (pa1, x, sizeof (pa1));           // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
120   memmove (pa2, x, sizeof pa2);             // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
121   memmove (pa3, x, sizeof (pa3));           // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
122   memmove (pa4, x, sizeof pa4);             // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
123   memmove (pa1, x, sizeof (struct A *));    // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
124   memmove (pa2, x, sizeof (PTA));           // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
125   memmove (pa3, x, sizeof (PA));            // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
126   memmove (pa4, x, sizeof (__typeof (pa4)));// { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
128   memmove (x, &a, sizeof (&a));             // { dg-warning "call is the same expression as the source; did you mean to remove the addressof" }
129   memmove (x, pa1, sizeof (pa1));           // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
130   memmove (x, pa2, sizeof pa2);             // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
131   memmove (x, pa3, sizeof (pa3));           // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
132   memmove (x, pa4, sizeof pa4);             // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
133   memmove (x, pa1, sizeof (struct A *));    // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
134   memmove (x, pa2, sizeof (PTA));           // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
135   memmove (x, pa3, sizeof (PA));            // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
136   memmove (x, pa4, sizeof (__typeof (pa4)));// { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
138   z += memcmp (&a, x, sizeof (&a));         // { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" }
139   z += memcmp (pa1, x, sizeof (pa1));       // { dg-warning "call is the same expression as the first source; did you mean to dereference it" }
140   z += memcmp (pa2, x, sizeof pa2);         // { dg-warning "call is the same expression as the first source; did you mean to dereference it" }
141   z += memcmp (pa3, x, sizeof (pa3));       // { dg-warning "call is the same expression as the first source; did you mean to dereference it" }
142   z += memcmp (pa4, x, sizeof pa4);         // { dg-warning "call is the same expression as the first source; did you mean to dereference it" }
143   z += memcmp (pa1, x, sizeof (struct A *));// { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" }
144   z += memcmp (pa2, x, sizeof (PTA));       // { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" }
145   z += memcmp (pa3, x, sizeof (PA));        // { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" }
147   z += memcmp (x, &a, sizeof (&a));         // { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" }
148   z += memcmp (x, pa1, sizeof (pa1));       // { dg-warning "call is the same expression as the second source; did you mean to dereference it" }
149   z += memcmp (x, pa2, sizeof pa2);         // { dg-warning "call is the same expression as the second source; did you mean to dereference it" }
150   z += memcmp (x, pa3, sizeof (pa3));       // { dg-warning "call is the same expression as the second source; did you mean to dereference it" }
151   z += memcmp (x, pa4, sizeof pa4);         // { dg-warning "call is the same expression as the second source; did you mean to dereference it" }
152   z += memcmp (x, pa1, sizeof (struct A *));// { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" }
153   z += memcmp (x, pa2, sizeof (PTA));       // { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" }
154   z += memcmp (x, pa3, sizeof (PA));        // { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" }
156   // These are correct, no warning. 
157   memset (&a, 0, sizeof a);
158   memset (&a, 0, sizeof (a));
159   memset (&a, 0, sizeof (struct A));
160   memset (&a, 0, sizeof (const struct A));
161   memset (&a, 0, sizeof (volatile struct A));
162   memset (&a, 0, sizeof (volatile const struct A));
163   memset (&a, 0, sizeof (TA));
164   memset (&a, 0, sizeof (__typeof (*&a)));
165   memset (pa1, 0, sizeof (*pa1));
166   memset (pa2, 0, sizeof (*pa3));
167   memset (pa3, 0, sizeof (__typeof (*pa3)));
168   // These are probably broken, but obfuscated, no warning. 
169   memset ((void *) &a, 0, sizeof (&a));
170   memset ((char *) &a, 0, sizeof (&a));
171   memset (&a, 0, sizeof (&a) + 0);
172   memset (&a, 0, 0 + sizeof (&a));
174   // These are correct, no warning. 
175   memcpy (&a, x, sizeof a);
176   memcpy (&a, x, sizeof (a));
177   memcpy (&a, x, sizeof (struct A));
178   memcpy (&a, x, sizeof (const struct A));
179   memcpy (&a, x, sizeof (volatile struct A));
180   memcpy (&a, x, sizeof (volatile const struct A));
181   memcpy (&a, x, sizeof (TA));
182   memcpy (&a, x, sizeof (__typeof (*&a)));
183   memcpy (pa1, x, sizeof (*pa1));
184   memcpy (pa2, x, sizeof (*pa3));
185   memcpy (pa3, x, sizeof (__typeof (*pa3)));
186   // These are probably broken, but obfuscated, no warning. 
187   memcpy ((void *) &a, x, sizeof (&a));
188   memcpy ((char *) &a, x, sizeof (&a));
189   memcpy (&a, x, sizeof (&a) + 0);
190   memcpy (&a, x, 0 + sizeof (&a));
192   // These are correct, no warning. 
193   memcpy (x, &a, sizeof a);
194   memcpy (x, &a, sizeof (a));
195   memcpy (x, &a, sizeof (struct A));
196   memcpy (x, &a, sizeof (const struct A));
197   memcpy (x, &a, sizeof (volatile struct A));
198   memcpy (x, &a, sizeof (volatile const struct A));
199   memcpy (x, &a, sizeof (TA));
200   memcpy (x, &a, sizeof (__typeof (*&a)));
201   memcpy (x, pa1, sizeof (*pa1));
202   memcpy (x, pa2, sizeof (*pa3));
203   memcpy (x, pa3, sizeof (__typeof (*pa3)));
204   // These are probably broken, but obfuscated, no warning. 
205   memcpy (x, (void *) &a, sizeof (&a));
206   memcpy (x, (char *) &a, sizeof (&a));
207   memcpy (x, &a, sizeof (&a) + 0);
208   memcpy (x, &a, 0 + sizeof (&a));
210   // These are correct, no warning. 
211   memmove (&a, x, sizeof a);
212   memmove (&a, x, sizeof (a));
213   memmove (&a, x, sizeof (struct A));
214   memmove (&a, x, sizeof (const struct A));
215   memmove (&a, x, sizeof (volatile struct A));
216   memmove (&a, x, sizeof (volatile const struct A));
217   memmove (&a, x, sizeof (TA));
218   memmove (&a, x, sizeof (__typeof (*&a)));
219   memmove (pa1, x, sizeof (*pa1));
220   memmove (pa2, x, sizeof (*pa3));
221   memmove (pa3, x, sizeof (__typeof (*pa3)));
222   // These are probably broken, but obfuscated, no warning. 
223   memmove ((void *) &a, x, sizeof (&a));
224   memmove ((char *) &a, x, sizeof (&a));
225   memmove (&a, x, sizeof (&a) + 0);
226   memmove (&a, x, 0 + sizeof (&a));
228   // These are correct, no warning. 
229   memmove (x, &a, sizeof a);
230   memmove (x, &a, sizeof (a));
231   memmove (x, &a, sizeof (struct A));
232   memmove (x, &a, sizeof (const struct A));
233   memmove (x, &a, sizeof (volatile struct A));
234   memmove (x, &a, sizeof (volatile const struct A));
235   memmove (x, &a, sizeof (TA));
236   memmove (x, &a, sizeof (__typeof (*&a)));
237   memmove (x, pa1, sizeof (*pa1));
238   memmove (x, pa2, sizeof (*pa3));
239   memmove (x, pa3, sizeof (__typeof (*pa3)));
240   // These are probably broken, but obfuscated, no warning. 
241   memmove (x, (void *) &a, sizeof (&a));
242   memmove (x, (char *) &a, sizeof (&a));
243   memmove (x, &a, sizeof (&a) + 0);
244   memmove (x, &a, 0 + sizeof (&a));
246   // These are correct, no warning. 
247   z += memcmp (&a, x, sizeof a);
248   z += memcmp (&a, x, sizeof (a));
249   z += memcmp (&a, x, sizeof (struct A));
250   z += memcmp (&a, x, sizeof (const struct A));
251   z += memcmp (&a, x, sizeof (volatile struct A));
252   z += memcmp (&a, x, sizeof (volatile const struct A));
253   z += memcmp (&a, x, sizeof (TA));
254   z += memcmp (&a, x, sizeof (__typeof (*&a)));
255   z += memcmp (pa1, x, sizeof (*pa1));
256   z += memcmp (pa2, x, sizeof (*pa3));
257   z += memcmp (pa3, x, sizeof (__typeof (*pa3)));
258   // These are probably broken, but obfuscated, no warning. 
259   z += memcmp ((void *) &a, x, sizeof (&a));
260   z += memcmp ((char *) &a, x, sizeof (&a));
261   z += memcmp (&a, x, sizeof (&a) + 0);
262   z += memcmp (&a, x, 0 + sizeof (&a));
264   // These are correct, no warning. 
265   z += memcmp (x, &a, sizeof a);
266   z += memcmp (x, &a, sizeof (a));
267   z += memcmp (x, &a, sizeof (struct A));
268   z += memcmp (x, &a, sizeof (const struct A));
269   z += memcmp (x, &a, sizeof (volatile struct A));
270   z += memcmp (x, &a, sizeof (volatile const struct A));
271   z += memcmp (x, &a, sizeof (TA));
272   z += memcmp (x, &a, sizeof (__typeof (*&a)));
273   z += memcmp (x, pa1, sizeof (*pa1));
274   z += memcmp (x, pa2, sizeof (*pa3));
275   z += memcmp (x, pa3, sizeof (__typeof (*pa3)));
276   // These are probably broken, but obfuscated, no warning. 
277   z += memcmp (x, (void *) &a, sizeof (&a));
278   z += memcmp (x, (char *) &a, sizeof (&a));
279   z += memcmp (x, &a, sizeof (&a) + 0);
280   z += memcmp (x, &a, 0 + sizeof (&a));
282   return z;
286 f2 (void *x, int z)
288   struct B b, *pb1 = &b;
289   TB *pb2 = &b;
290   PB pb3 = &b;
291   PTB pb4 = &b;
292   memset (&b, 0, sizeof (&b));              // { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" }
293   memset (pb1, 0, sizeof (pb1));            // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
294   memset (pb2, 0, sizeof pb2);              // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
295   memset (pb3, 0, sizeof (pb3));            // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
296   memset (pb4, 0, sizeof pb4);              // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
297   memset (pb1, 0, sizeof (struct B *));     // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
298   memset (pb2, 0, sizeof (PTB));            // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
299   memset (pb3, 0, sizeof (PB));             // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
300   memset (pb4, 0, sizeof (__typeof (pb4))); // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
302   memcpy (&b, x, sizeof (&b));              // { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" }
303   memcpy (pb1, x, sizeof (pb1));            // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
304   memcpy (pb2, x, sizeof pb2);              // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
305   memcpy (pb3, x, sizeof (pb3));            // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
306   memcpy (pb4, x, sizeof pb4);              // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
307   memcpy (pb1, x, sizeof (struct B *));     // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
308   memcpy (pb2, x, sizeof (PTB));            // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
309   memcpy (pb3, x, sizeof (PB));             // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
310   memcpy (pb4, x, sizeof (__typeof (pb4))); // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
312   memcpy (x, &b, sizeof (&b));              // { dg-warning "call is the same expression as the source; did you mean to remove the addressof" }
313   memcpy (x, pb1, sizeof (pb1));            // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
314   memcpy (x, pb2, sizeof pb2);              // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
315   memcpy (x, pb3, sizeof (pb3));            // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
316   memcpy (x, pb4, sizeof pb4);              // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
317   memcpy (x, pb1, sizeof (struct B *));     // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
318   memcpy (x, pb2, sizeof (PTB));            // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
319   memcpy (x, pb3, sizeof (PB));             // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
320   memcpy (x, pb4, sizeof (__typeof (pb4))); // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
322   memmove (&b, x, sizeof (&b));             // { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" }
323   memmove (pb1, x, sizeof (pb1));           // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
324   memmove (pb2, x, sizeof pb2);             // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
325   memmove (pb3, x, sizeof (pb3));           // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
326   memmove (pb4, x, sizeof pb4);             // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
327   memmove (pb1, x, sizeof (struct B *));    // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
328   memmove (pb2, x, sizeof (PTB));           // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
329   memmove (pb3, x, sizeof (PB));            // { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
330   memmove (pb4, x, sizeof (__typeof (pb4)));// { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" }
332   memmove (x, &b, sizeof (&b));             // { dg-warning "call is the same expression as the source; did you mean to remove the addressof" }
333   memmove (x, pb1, sizeof (pb1));           // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
334   memmove (x, pb2, sizeof pb2);             // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
335   memmove (x, pb3, sizeof (pb3));           // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
336   memmove (x, pb4, sizeof pb4);             // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
337   memmove (x, pb1, sizeof (struct B *));    // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
338   memmove (x, pb2, sizeof (PTB));           // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
339   memmove (x, pb3, sizeof (PB));            // { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
340   memmove (x, pb4, sizeof (__typeof (pb4)));// { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" }
342   z += memcmp (&b, x, sizeof (&b));         // { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" }
343   z += memcmp (pb1, x, sizeof (pb1));       // { dg-warning "call is the same expression as the first source; did you mean to dereference it" }
344   z += memcmp (pb2, x, sizeof pb2);         // { dg-warning "call is the same expression as the first source; did you mean to dereference it" }
345   z += memcmp (pb3, x, sizeof (pb3));       // { dg-warning "call is the same expression as the first source; did you mean to dereference it" }
346   z += memcmp (pb4, x, sizeof pb4);         // { dg-warning "call is the same expression as the first source; did you mean to dereference it" }
347   z += memcmp (pb1, x, sizeof (struct B *));// { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" }
348   z += memcmp (pb2, x, sizeof (PTB));       // { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" }
349   z += memcmp (pb3, x, sizeof (PB));        // { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" }
351   z += memcmp (x, &b, sizeof (&b));         // { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" }
352   z += memcmp (x, pb1, sizeof (pb1));       // { dg-warning "call is the same expression as the second source; did you mean to dereference it" }
353   z += memcmp (x, pb2, sizeof pb2);         // { dg-warning "call is the same expression as the second source; did you mean to dereference it" }
354   z += memcmp (x, pb3, sizeof (pb3));       // { dg-warning "call is the same expression as the second source; did you mean to dereference it" }
355   z += memcmp (x, pb4, sizeof pb4);         // { dg-warning "call is the same expression as the second source; did you mean to dereference it" }
356   z += memcmp (x, pb1, sizeof (struct B *));// { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" }
357   z += memcmp (x, pb2, sizeof (PTB));       // { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" }
358   z += memcmp (x, pb3, sizeof (PB));        // { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" }
360   // These are correct, no warning. 
361   memset (&b, 0, sizeof b);
362   memset (&b, 0, sizeof (b));
363   memset (&b, 0, sizeof (struct B));
364   memset (&b, 0, sizeof (const struct B));
365   memset (&b, 0, sizeof (volatile struct B));
366   memset (&b, 0, sizeof (volatile const struct B));
367   memset (&b, 0, sizeof (TB));
368   memset (&b, 0, sizeof (__typeof (*&b)));
369   memset (pb1, 0, sizeof (*pb1));
370   memset (pb2, 0, sizeof (*pb3));
371   memset (pb3, 0, sizeof (__typeof (*pb3)));
372   // These are probably broken, but obfuscated, no warning. 
373   memset ((void *) &b, 0, sizeof (&b));
374   memset ((char *) &b, 0, sizeof (&b));
375   memset (&b, 0, sizeof (&b) + 0);
376   memset (&b, 0, 0 + sizeof (&b));
378   // These are correct, no warning. 
379   memcpy (&b, x, sizeof b);
380   memcpy (&b, x, sizeof (b));
381   memcpy (&b, x, sizeof (struct B));
382   memcpy (&b, x, sizeof (const struct B));
383   memcpy (&b, x, sizeof (volatile struct B));
384   memcpy (&b, x, sizeof (volatile const struct B));
385   memcpy (&b, x, sizeof (TB));
386   memcpy (&b, x, sizeof (__typeof (*&b)));
387   memcpy (pb1, x, sizeof (*pb1));
388   memcpy (pb2, x, sizeof (*pb3));
389   memcpy (pb3, x, sizeof (__typeof (*pb3)));
390   // These are probably broken, but obfuscated, no warning. 
391   memcpy ((void *) &b, x, sizeof (&b));
392   memcpy ((char *) &b, x, sizeof (&b));
393   memcpy (&b, x, sizeof (&b) + 0);
394   memcpy (&b, x, 0 + sizeof (&b));
396   // These are correct, no warning. 
397   memcpy (x, &b, sizeof b);
398   memcpy (x, &b, sizeof (b));
399   memcpy (x, &b, sizeof (struct B));
400   memcpy (x, &b, sizeof (const struct B));
401   memcpy (x, &b, sizeof (volatile struct B));
402   memcpy (x, &b, sizeof (volatile const struct B));
403   memcpy (x, &b, sizeof (TB));
404   memcpy (x, &b, sizeof (__typeof (*&b)));
405   memcpy (x, pb1, sizeof (*pb1));
406   memcpy (x, pb2, sizeof (*pb3));
407   memcpy (x, pb3, sizeof (__typeof (*pb3)));
408   // These are probably broken, but obfuscated, no warning. 
409   memcpy (x, (void *) &b, sizeof (&b));
410   memcpy (x, (char *) &b, sizeof (&b));
411   memcpy (x, &b, sizeof (&b) + 0);
412   memcpy (x, &b, 0 + sizeof (&b));
414   // These are correct, no warning. 
415   memmove (&b, x, sizeof b);
416   memmove (&b, x, sizeof (b));
417   memmove (&b, x, sizeof (struct B));
418   memmove (&b, x, sizeof (const struct B));
419   memmove (&b, x, sizeof (volatile struct B));
420   memmove (&b, x, sizeof (volatile const struct B));
421   memmove (&b, x, sizeof (TB));
422   memmove (&b, x, sizeof (__typeof (*&b)));
423   memmove (pb1, x, sizeof (*pb1));
424   memmove (pb2, x, sizeof (*pb3));
425   memmove (pb3, x, sizeof (__typeof (*pb3)));
426   // These are probably broken, but obfuscated, no warning. 
427   memmove ((void *) &b, x, sizeof (&b));
428   memmove ((char *) &b, x, sizeof (&b));
429   memmove (&b, x, sizeof (&b) + 0);
430   memmove (&b, x, 0 + sizeof (&b));
432   // These are correct, no warning. 
433   memmove (x, &b, sizeof b);
434   memmove (x, &b, sizeof (b));
435   memmove (x, &b, sizeof (struct B));
436   memmove (x, &b, sizeof (const struct B));
437   memmove (x, &b, sizeof (volatile struct B));
438   memmove (x, &b, sizeof (volatile const struct B));
439   memmove (x, &b, sizeof (TB));
440   memmove (x, &b, sizeof (__typeof (*&b)));
441   memmove (x, pb1, sizeof (*pb1));
442   memmove (x, pb2, sizeof (*pb3));
443   memmove (x, pb3, sizeof (__typeof (*pb3)));
444   // These are probably broken, but obfuscated, no warning. 
445   memmove (x, (void *) &b, sizeof (&b));
446   memmove (x, (char *) &b, sizeof (&b));
447   memmove (x, &b, sizeof (&b) + 0);
448   memmove (x, &b, 0 + sizeof (&b));
450   // These are correct, no warning. 
451   z += memcmp (&b, x, sizeof b);
452   z += memcmp (&b, x, sizeof (b));
453   z += memcmp (&b, x, sizeof (struct B));
454   z += memcmp (&b, x, sizeof (const struct B));
455   z += memcmp (&b, x, sizeof (volatile struct B));
456   z += memcmp (&b, x, sizeof (volatile const struct B));
457   z += memcmp (&b, x, sizeof (TB));
458   z += memcmp (&b, x, sizeof (__typeof (*&b)));
459   z += memcmp (pb1, x, sizeof (*pb1));
460   z += memcmp (pb2, x, sizeof (*pb3));
461   z += memcmp (pb3, x, sizeof (__typeof (*pb3)));
462   // These are probably broken, but obfuscated, no warning. 
463   z += memcmp ((void *) &b, x, sizeof (&b));
464   z += memcmp ((char *) &b, x, sizeof (&b));
465   z += memcmp (&b, x, sizeof (&b) + 0);
466   z += memcmp (&b, x, 0 + sizeof (&b));
468   // These are correct, no warning. 
469   z += memcmp (x, &b, sizeof b);
470   z += memcmp (x, &b, sizeof (b));
471   z += memcmp (x, &b, sizeof (struct B));
472   z += memcmp (x, &b, sizeof (const struct B));
473   z += memcmp (x, &b, sizeof (volatile struct B));
474   z += memcmp (x, &b, sizeof (volatile const struct B));
475   z += memcmp (x, &b, sizeof (TB));
476   z += memcmp (x, &b, sizeof (__typeof (*&b)));
477   z += memcmp (x, pb1, sizeof (*pb1));
478   z += memcmp (x, pb2, sizeof (*pb3));
479   z += memcmp (x, pb3, sizeof (__typeof (*pb3)));
480   // These are probably broken, but obfuscated, no warning. 
481   z += memcmp (x, (void *) &b, sizeof (&b));
482   z += memcmp (x, (char *) &b, sizeof (&b));
483   z += memcmp (x, &b, sizeof (&b) + 0);
484   z += memcmp (x, &b, 0 + sizeof (&b));
486   return z;
490 f3 (void *x, char *y, int z, X w)
492   unsigned char *y1 = (unsigned char *) __builtin_alloca (z + 16);
493   char buf1[7];
494   signed char buf2[z + 32];
495   long buf3[17];
496   int *buf4[9];
497   signed char *y2 = buf2;
498   char c;
499   char *y3;
500   memset (y, 0, sizeof (y));                // { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" }
501   memset (y1, 0, sizeof (y1));              // { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" }
502   memset (y2, 0, sizeof (y2));              // { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" }
503   memset (&c, 0, sizeof (&c));              // { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" }
504   memset (w, 0, sizeof w);                  // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
506   memcpy (y, x, sizeof (y));                // { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" }
507   memcpy (y1, x, sizeof (y1));              // { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" }
508   memcpy (y2, x, sizeof (y2));              // { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" }
509   memcpy (&c, x, sizeof (&c));              // { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" }
510   memcpy (w, x, sizeof w);                  // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
512   memcpy (x, y, sizeof (y));                // { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" }
513   memcpy (x, y1, sizeof (y1));              // { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" }
514   memcpy (x, y2, sizeof (y2));              // { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" }
515   memcpy (x, &c, sizeof (&c));              // { dg-warning "call is the same expression as the source; did you mean to remove the addressof" }
516   memcpy (x, w, sizeof w);                  // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
518   memmove (y, x, sizeof (y));               // { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" }
519   memmove (y1, x, sizeof (y1));             // { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" }
520   memmove (y2, x, sizeof (y2));             // { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" }
521   memmove (&c, x, sizeof (&c));             // { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" }
522   memmove (w, x, sizeof w);                 // { dg-warning "call is the same expression as the destination; did you mean to dereference it" }
524   memmove (x, y, sizeof (y));               // { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" }
525   memmove (x, y1, sizeof (y1));             // { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" }
526   memmove (x, y2, sizeof (y2));             // { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" }
527   memmove (x, &c, sizeof (&c));             // { dg-warning "call is the same expression as the source; did you mean to remove the addressof" }
528   memmove (x, w, sizeof w);                 // { dg-warning "call is the same expression as the source; did you mean to dereference it" }
530   z += memcmp (y, x, sizeof (y));           // { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" }
531   z += memcmp (y1, x, sizeof (y1));         // { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" }
532   z += memcmp (y2, x, sizeof (y2));         // { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" }
533   z += memcmp (&c, x, sizeof (&c));         // { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" }
534   z += memcmp (w, x, sizeof w);             // { dg-warning "call is the same expression as the first source; did you mean to dereference it" }
536   z += memcmp (x, y, sizeof (y));           // { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" }
537   z += memcmp (x, y1, sizeof (y1));         // { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" }
538   z += memcmp (x, y2, sizeof (y2));         // { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" }
539   z += memcmp (x, &c, sizeof (&c));         // { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" }
540   z += memcmp (x, w, sizeof w);             // { dg-warning "call is the same expression as the second source; did you mean to dereference it" }
542   // These are correct, no warning. 
543   memset (y, 0, sizeof (*y));
544   memset (y1, 0, sizeof (*y2));
545   memset (buf1, 0, sizeof buf1);
546   memset (buf3, 0, sizeof (buf3));
547   memset (&buf3[0], 0, sizeof (buf3));
548   memset (&buf4[0], 0, sizeof (buf4));
549   memset (w, 0, sizeof (X));
550   // These are probably broken, but obfuscated, no warning. 
551   memset ((void *) y, 0, sizeof (y));
552   memset ((char *) y1, 0, sizeof (y2));
553   memset (y, 0, sizeof (y) + 0);
554   memset (y1, 0, 0 + sizeof (y2));
555   memset ((void *) &c, 0, sizeof (&c));
556   memset ((signed char *) &c, 0, sizeof (&c));
557   memset (&c, 0, sizeof (&c) + 0);
558   memset (&c, 0, 0 + sizeof (&c));
560   // These are correct, no warning. 
561   memcpy (y, x, sizeof (*y));
562   memcpy (y1, x, sizeof (*y2));
563   memcpy (buf1, x, sizeof buf1);
564   memcpy (buf3, x, sizeof (buf3));
565   memcpy (&buf3[0], x, sizeof (buf3));
566   memcpy (&buf4[0], x, sizeof (buf4));
567   memcpy (&y3, y, sizeof (y3));
568   memcpy ((char *) &y3, y, sizeof (y3));
569   memcpy (w, x, sizeof (X));
570   // These are probably broken, but obfuscated, no warning. 
571   memcpy ((void *) y, x, sizeof (y));
572   memcpy ((char *) y1, x, sizeof (y2));
573   memcpy (y, x, sizeof (y) + 0);
574   memcpy (y1, x, 0 + sizeof (y2));
575   memcpy ((void *) &c, x, sizeof (&c));
576   memcpy ((signed char *) &c, x, sizeof (&c));
577   memcpy (&c, x, sizeof (&c) + 0);
578   memcpy (&c, x, 0 + sizeof (&c));
580   // These are correct, no warning. 
581   memcpy (x, y, sizeof (*y));
582   memcpy (x, y1, sizeof (*y2));
583   memcpy (x, buf1, sizeof buf1);
584   memcpy (x, buf3, sizeof (buf3));
585   memcpy (x, &buf3[0], sizeof (buf3));
586   memcpy (x, &buf4[0], sizeof (buf4));
587   memcpy (y, &y3, sizeof (y3));
588   memcpy (y, (char *) &y3, sizeof (y3));
589   memcpy (x, w, sizeof (X));
590   // These are probably broken, but obfuscated, no warning. 
591   memcpy (x, (void *) y, sizeof (y));
592   memcpy (x, (char *) y1, sizeof (y2));
593   memcpy (x, y, sizeof (y) + 0);
594   memcpy (x, y1, 0 + sizeof (y2));
595   memcpy (x, (void *) &c, sizeof (&c));
596   memcpy (x, (signed char *) &c, sizeof (&c));
597   memcpy (x, &c, sizeof (&c) + 0);
598   memcpy (x, &c, 0 + sizeof (&c));
600   // These are correct, no warning. 
601   memmove (y, x, sizeof (*y));
602   memmove (y1, x, sizeof (*y2));
603   memmove (buf1, x, sizeof buf1);
604   memmove (buf3, x, sizeof (buf3));
605   memmove (&buf3[0], x, sizeof (buf3));
606   memmove (&buf4[0], x, sizeof (buf4));
607   memmove (&y3, y, sizeof (y3));
608   memmove ((char *) &y3, y, sizeof (y3));
609   memmove (w, x, sizeof (X));
610   // These are probably broken, but obfuscated, no warning. 
611   memmove ((void *) y, x, sizeof (y));
612   memmove ((char *) y1, x, sizeof (y2));
613   memmove (y, x, sizeof (y) + 0);
614   memmove (y1, x, 0 + sizeof (y2));
615   memmove ((void *) &c, x, sizeof (&c));
616   memmove ((signed char *) &c, x, sizeof (&c));
617   memmove (&c, x, sizeof (&c) + 0);
618   memmove (&c, x, 0 + sizeof (&c));
620   // These are correct, no warning. 
621   memmove (x, y, sizeof (*y));
622   memmove (x, y1, sizeof (*y2));
623   memmove (x, buf1, sizeof buf1);
624   memmove (x, buf3, sizeof (buf3));
625   memmove (x, &buf3[0], sizeof (buf3));
626   memmove (x, &buf4[0], sizeof (buf4));
627   memmove (y, &y3, sizeof (y3));
628   memmove (y, (char *) &y3, sizeof (y3));
629   memmove (x, w, sizeof (X));
630   // These are probably broken, but obfuscated, no warning. 
631   memmove (x, (void *) y, sizeof (y));
632   memmove (x, (char *) y1, sizeof (y2));
633   memmove (x, y, sizeof (y) + 0);
634   memmove (x, y1, 0 + sizeof (y2));
635   memmove (x, (void *) &c, sizeof (&c));
636   memmove (x, (signed char *) &c, sizeof (&c));
637   memmove (x, &c, sizeof (&c) + 0);
638   memmove (x, &c, 0 + sizeof (&c));
640   // These are correct, no warning. 
641   z += memcmp (y, x, sizeof (*y));
642   z += memcmp (y1, x, sizeof (*y2));
643   z += memcmp (buf1, x, sizeof buf1);
644   z += memcmp (buf3, x, sizeof (buf3));
645   z += memcmp (&buf3[0], x, sizeof (buf3));
646   z += memcmp (&buf4[0], x, sizeof (buf4));
647   z += memcmp (&y3, y, sizeof (y3));
648   z += memcmp ((char *) &y3, y, sizeof (y3));
649   z += memcmp (w, x, sizeof (X));
650   // These are probably broken, but obfuscated, no warning. 
651   z += memcmp ((void *) y, x, sizeof (y));
652   z += memcmp ((char *) y1, x, sizeof (y2));
653   z += memcmp (y, x, sizeof (y) + 0);
654   z += memcmp (y1, x, 0 + sizeof (y2));
655   z += memcmp ((void *) &c, x, sizeof (&c));
656   z += memcmp ((signed char *) &c, x, sizeof (&c));
657   z += memcmp (&c, x, sizeof (&c) + 0);
658   z += memcmp (&c, x, 0 + sizeof (&c));
660   // These are correct, no warning. 
661   z += memcmp (x, y, sizeof (*y));
662   z += memcmp (x, y1, sizeof (*y2));
663   z += memcmp (x, buf1, sizeof buf1);
664   z += memcmp (x, buf3, sizeof (buf3));
665   z += memcmp (x, &buf3[0], sizeof (buf3));
666   z += memcmp (x, &buf4[0], sizeof (buf4));
667   z += memcmp (y, &y3, sizeof (y3));
668   z += memcmp (y, (char *) &y3, sizeof (y3));
669   z += memcmp (x, w, sizeof (X));
670   // These are probably broken, but obfuscated, no warning. 
671   z += memcmp (x, (void *) y, sizeof (y));
672   z += memcmp (x, (char *) y1, sizeof (y2));
673   z += memcmp (x, y, sizeof (y) + 0);
674   z += memcmp (x, y1, 0 + sizeof (y2));
675   z += memcmp (x, (void *) &c, sizeof (&c));
676   z += memcmp (x, (signed char *) &c, sizeof (&c));
677   z += memcmp (x, &c, sizeof (&c) + 0);
678   z += memcmp (x, &c, 0 + sizeof (&c));
680   return z;
684 f4 (char *x, char **y, int z, char w[64])
686   const char *s1 = "foobarbaz";
687   const char *s2 = "abcde12345678";
688   strncpy (x, s1, sizeof (s1));             // { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" }
689   strncat (x, s2, sizeof (s2));             // { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" }
690   stpncpy (x, s1, sizeof (s1));             // { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" }
691   y[0] = strndup (s1, sizeof (s1));         // { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" }
692   z += strncmp (s1, s2, sizeof (s1));       // { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" }
693   z += strncmp (s1, s2, sizeof (s2));       // { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" }
694   z += strncasecmp (s1, s2, sizeof (s1));   // { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" }
695   z += strncasecmp (s1, s2, sizeof (s2));   // { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" }
697   strncpy (w, s1, sizeof (w));              // { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" }
698   strncat (w, s2, sizeof (w));              // { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" }
699   stpncpy (w, s1, sizeof (w));              // { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" }
701   // These are correct, no warning. 
702   const char s3[] = "foobarbaz";
703   const char s4[] = "abcde12345678";
704   strncpy (x, s3, sizeof (s3));
705   strncat (x, s4, sizeof (s4));
706   stpncpy (x, s3, sizeof (s3));
707   y[1] = strndup (s3, sizeof (s3));
708   z += strncmp (s3, s4, sizeof (s3));
709   z += strncmp (s3, s4, sizeof (s4));
710   z += strncasecmp (s3, s4, sizeof (s3));
711   z += strncasecmp (s3, s4, sizeof (s4));
713   return z;
716 // { dg-prune-output "\[\n\r\]*will always overflow\[\n\r\]*" }