gcc/testsuite/gcc.dg/Wstringop-overflow-14-novec.c
raw| 1 | /* Test to verify that past-the-end multibyte writes via lvalues of wider |
| 2 | types than char are diagnosed. |
| 3 | { dg-do compile } |
| 4 | { dg-require-effective-target int32plus } |
| 5 | { dg-options "-O2 -fno-tree-vectorize -Wall -Wno-array-bounds" } */ |
| 6 | |
| 7 | typedef __INT16_TYPE__ int16_t; |
| 8 | |
| 9 | char a4[4], a8[8], a16[16]; |
| 10 | |
| 11 | void test_int16 (void) |
| 12 | { |
| 13 | char *p = a4 + 1; |
| 14 | *(int16_t*)p = 0; |
| 15 | *(int16_t*)(p + 2) = 0; // { dg-warning "writing 2 bytes into a region of size 1" } |
| 16 | } |