gcc/testsuite/c-c++-common/Wstringop-truncation-3.c
raw| 1 | /* PR tree-optimization/84228 */ |
| 2 | /* { dg-do compile } */ |
| 3 | /* { dg-options "-Wstringop-truncation -O2 -g" } */ |
| 4 | |
| 5 | char *strncpy (char *, const char *, __SIZE_TYPE__); |
| 6 | struct S |
| 7 | { |
| 8 | char arr[64]; |
| 9 | }; |
| 10 | |
| 11 | int |
| 12 | foo (struct S *p1, const char *a) |
| 13 | { |
| 14 | int b = 5, c = 6, d = 7; |
| 15 | if (a) |
| 16 | goto err; |
| 17 | strncpy (p1->arr, a, sizeof p1->arr); /* { dg-bogus "specified bound" } */ |
| 18 | b = 8; c = 9; d = 10; |
| 19 | p1->arr[3] = '\0'; |
| 20 | err: |
| 21 | return 0; |
| 22 | } |