PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / pr82596.c
blob5dc67c28e8c792e6feb572b82830994f7643e1ed
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" } */
6 #define SIZE_MAX __SIZE_MAX__
7 #define SSIZE_MAX __PTRDIFF_MAX__
8 #define SSIZE_MIN (-SSIZE_MAX - 1)
10 void sink (int, ...);
12 #define T(arg) sink (arg)
14 void test_cststring (int i)
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" } */