| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-Walloca-larger-than=123 -O2" } */ |
| 3 |
/* { dg-xfail-if "Currently broken but Andrew's work should fix this" { *-*-* } } */ |
| 4 |
|
| 5 |
/* The argument to alloca ends up having a range of 0..MAXINT(32bits), |
| 6 |
so we think we have a range because of the upcast. Consequently, |
| 7 |
we warn with "alloca may be too large", but we should technically |
| 8 |
warn with "unbounded use of alloca". |
| 9 |
|
| 10 |
We currently drill through casts to figure this stuff out, but we |
| 11 |
get confused because it's not just a cast. It's a cast, plus a |
| 12 |
multiply. |
| 13 |
|
| 14 |
<bb 2>: |
| 15 |
# RANGE [0, 4294967295] NONZERO 4294967295 |
| 16 |
_1 = (long unsigned int) something_4(D); |
| 17 |
# RANGE [0, 34359738360] NONZERO 34359738360 |
| 18 |
_2 = _1 * 8; |
| 19 |
_3 = __builtin_alloca (_2); |
| 20 |
|
| 21 |
I don't know whether it's even worth such fine-grained warnings. |
| 22 |
Perhaps we should generically warn everywhere with "alloca may be |
| 23 |
too large". |
| 24 |
|
| 25 |
I'm hoping that this particular case will be easier to diagnose with |
| 26 |
Andrew's work. */ |
| 27 |
|
| 28 |
void useit(void *); |
| 29 |
void foobar(unsigned int something) |
| 30 |
{ |
| 31 |
useit(__builtin_alloca (something * sizeof (const char *))); // { dg-warning "unbounded use of alloca" "" { xfail *-*-* } } |
| 32 |
} |