Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/g++.dg/ext/strncpy-chk1.C @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/g++.dg/ext/strncpy-chk1.C Fri Oct 27 22:46:09 2017 +0900 @@ -0,0 +1,32 @@ +// PR c++/40502 +// { dg-do compile } +// { dg-options "-O2" } +// { dg-skip-if "packed attribute missing for struct A" { "epiphany-*-*" } } + +struct A { char x[12], y[35]; }; +struct B { char z[50]; }; + +inline void +foo (char *dest, const char *__restrict src, __SIZE_TYPE__ n) +{ + __builtin___strncpy_chk (dest, src, n, __builtin_object_size (dest, 0)); // { dg-warning "specified bound 36 exceeds destination size 35" } +} + +void bar (const char *, int); + +inline void +baz (int i) +{ + char s[128], t[32]; + bar (s, 0); + bar (t, i); + A a; + B b; + foo (a.y, b.z, 36); +} + +void +test () +{ + baz (0); +}