| 1 |
/* PR tree-optimization/88800 - Spurious -Werror=array-bounds for non-taken |
| 2 |
branch |
| 3 |
Verify that out-of-bounds memcpy calls are not folded when warnings are |
| 4 |
enabled (builtin-memcpy-2.c verifies they're not folded with warnings |
| 5 |
disabled). |
| 6 |
{ dg-do compile } |
| 7 |
{ dg-options "-O2 -Wall -fdump-tree-optimized" } */ |
| 8 |
|
| 9 |
extern void* memcpy (void*, const void*, __SIZE_TYPE__); |
| 10 |
|
| 11 |
char a1[1], a2[2], a4[4], a8[8], a16[16], a32[32]; |
| 12 |
|
| 13 |
void f1 (const void *p) |
| 14 |
{ |
| 15 |
memcpy (a1, p, sizeof a1 * 2); /* { dg-warning "\\\[-Warray-bounds" } */ |
| 16 |
} |
| 17 |
|
| 18 |
void f2 (const void *p) |
| 19 |
{ |
| 20 |
memcpy (a2, p, sizeof a2 * 2); /* { dg-warning "\\\[-Warray-bounds" } */ |
| 21 |
} |
| 22 |
|
| 23 |
void f4 (const void *p) |
| 24 |
{ |
| 25 |
memcpy (a4, p, sizeof a4 * 2); /* { dg-warning "\\\[-Warray-bounds" } */ |
| 26 |
} |
| 27 |
|
| 28 |
void f8 (const void *p) |
| 29 |
{ |
| 30 |
memcpy (a8, p, sizeof a8 * 2); /* { dg-warning "\\\[-Warray-bounds" } */ |
| 31 |
} |
| 32 |
|
| 33 |
void f16 (const void *p) |
| 34 |
{ |
| 35 |
memcpy (a16, p, sizeof a16 * 2); /* { dg-warning "\\\[-Warray-bounds" } */ |
| 36 |
} |
| 37 |
|
| 38 |
void f32 (const void *p) |
| 39 |
{ |
| 40 |
memcpy (a32, p, sizeof a32 * 2); /* { dg-warning "\\\[-Warray-bounds" } */ |
| 41 |
} |
| 42 |
|
| 43 |
/* { dg-final { scan-tree-dump-times "memcpy" 6 "optimized" } } */ |