comparison gcc/testsuite/g++.dg/warn/Wstringop-overflow-1.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 // { dg-do compile }
2 // { dg-additional-options "-O2 -Wstringop-overflow=2" }
3
4 struct S {
5 char a[5];
6 void (*pf)(void);
7 };
8
9 void f (struct S *s, int n)
10 {
11 if (n < sizeof s->a + 1)
12 n = sizeof s->a + 1;
13
14 __builtin_strncpy (s->a, "123456", n); // { dg-warning "writing 6" }
15 }