gcc/testsuite/c-c++-common/ubsan/pr66908.c
raw| 1 | /* PR sanitizer/66908 */ |
| 2 | /* { dg-do compile } */ |
| 3 | /* { dg-options "-fsanitize=shift,bounds -O2 -Werror=maybe-uninitialized" } */ |
| 4 | /* { dg-additional-options "-std=gnu90" { target c } } */ |
| 5 | |
| 6 | struct S { int a[22]; }; |
| 7 | static int const e[22] = { }; |
| 8 | |
| 9 | void |
| 10 | foo (struct S const *s, unsigned int m, unsigned int *res) |
| 11 | { |
| 12 | unsigned int i; |
| 13 | for (i = 0; i < 22; ++i) |
| 14 | res[i] = ((s->a[i] + e[i]) << m); |
| 15 | } |