| 1 |
/* PR tree-optimization/82596 - missing -Warray-bounds on an out-of-bounds |
| 2 |
index into string literal |
| 3 |
{ dg-do compile } |
| 4 |
{ dg-options "-O2 -Warray-bounds" } */ |
| 5 |
|
| 6 |
#define SIZE_MAX __SIZE_MAX__ |
| 7 |
#define SSIZE_MAX __PTRDIFF_MAX__ |
| 8 |
#define SSIZE_MIN (-SSIZE_MAX - 1) |
| 9 |
|
| 10 |
void sink (int, ...); |
| 11 |
|
| 12 |
#define T(arg) sink (arg) |
| 13 |
|
| 14 |
void test_cststring (int i) |
| 15 |
{ |
| 16 |
T (""[SSIZE_MIN]); /* { dg-warning "below array bounds" "string" { xfail lp64 } } */ |
| 17 |
T (""[SSIZE_MIN + 1]); /* { dg-warning "below array bounds" "string" } */ |
| 18 |
T (""[-1]); /* { dg-warning "below array bounds" "string" } */ |
| 19 |
T (""[0]); |
| 20 |
T (""[1]); /* { dg-warning "above array bounds" "string" } */ |
| 21 |
T ("0"[2]); /* { dg-warning "above array bounds" "string" } */ |
| 22 |
T ("012"[2]); |
| 23 |
T ("012"[3]); |
| 24 |
T ("012"[4]); /* { dg-warning "above array bounds" "string" } */ |
| 25 |
T ("0123"[SSIZE_MAX]); /* { dg-warning "above array bounds" "string" } */ |
| 26 |
T ("0123"[SIZE_MAX]); /* { dg-warning "above array bounds" "string" } */ |
| 27 |
} |