Debian Codegraph @

gcc/testsuite/gcc.dg/ubsan/c-shift-1.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fsanitize=shift -w" } */
3 /* { dg-shouldfail "ubsan" } */
4
5 int x;
6 int
7 main (void)
8 {
9 /* None of the following should pass. */
10 int A[1 >> -1] = { 0 }; /* { dg-error "variable-sized object may not be initialized" } */
11 int B[-1 >> -1] = { 0 }; /* { dg-error "variable-sized object may not be initialized" } */
12 int D[1 << -1] = { 0 }; /* { dg-error "variable-sized object may not be initialized" } */
13 int E[-1 << -1] = { 0 }; /* { dg-error "variable-sized object may not be initialized" } */
14 int F[-1 >> 200] = { 0 }; /* { dg-error "variable-sized object may not be initialized" } */
15 int G[1 << 200] = { 0 }; /* { dg-error "variable-sized object may not be initialized" } */
16
17 return 0;
18 }