comparison gcc/testsuite/c-c++-common/Wstringop-truncation-3.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
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 }