1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3
4 typedef __SIZE_TYPE__ size_t;
5
6 extern void warn_memset_zero_len (void)
7 __attribute__((__warning__ ("memset used with constant zero length parameter;"
8 " this could be due to transposed parameters")));
9
10 extern inline __attribute__((gnu_inline, always_inline, artificial)) void *
memset(void * dest,int ch,size_t len)11 memset (void *dest, int ch, size_t len)
12 {
13 if (__builtin_constant_p (len) && len == 0)
14 {
15 warn_memset_zero_len (); /* { dg-warning "memset used with constant zero" } */
16 return dest;
17 }
18 return __builtin_memset (dest, ch, len);
19 }
20
21 char buf[10];
22
23 int
main(void)24 main (void)
25 {
26 memset (buf, sizeof (buf), 0);
27 return 0;
28 }
29