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