| 1 |
/* PR middle-end/99578 */ |
| 2 |
/* { dg-do compile { target int32 } } */ |
| 3 |
/* { dg-options "-O2 -Wstringop-overflow" } */ |
| 4 |
|
| 5 |
struct S { int a, b[4]; }; |
| 6 |
struct T { int a, b[8192], c[4]; }; |
| 7 |
|
| 8 |
void |
| 9 |
foo (struct S *p) |
| 10 |
{ |
| 11 |
if (p) return; |
| 12 |
__builtin_memset (p->b, 0, sizeof p->b); /* { dg-warning "writing 16 bytes into a region of size 0 overflows the destination" } */ |
| 13 |
} |
| 14 |
|
| 15 |
void |
| 16 |
bar (struct T *p) |
| 17 |
{ |
| 18 |
if (p) return; |
| 19 |
__builtin_memset (p->c, 0, sizeof p->c); /* { dg-warning "writing 16 bytes into a region of size 0 overflows the destination" "" { xfail *-*-* } } */ |
| 20 |
} |
| 21 |
|
| 22 |
void |
| 23 |
baz (void) |
| 24 |
{ |
| 25 |
__builtin_memset ((void *) 0x8004, 0, 16); /* { dg-bogus "overflows the destination" } */ |
| 26 |
} |