Debian Codegraph @

gcc/testsuite/g++.dg/warn/Warray-bounds-27.C

raw
1 // PR105726
2 // { dg-do compile }
3 // { dg-require-effective-target c++11 }
4 // { dg-options "-O2 -Warray-bounds" }
5 // { dg-skip-if "requires hosted libstdc++ for cstring" { ! hostedlib } }
6
7 #include <array>
8 #include <cstring>
9
10 struct X {
11 char pad[4];
12 std::array<char, 1> mField;
13 };
14
15 void encode(char* aBuffer, const X& aMessage) {
16 strncpy(aBuffer, aMessage.mField.data(), 1); // { dg-bogus "bounds" }
17 }