libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/117983.cc
raw| 1 | // { dg-options "-O3 -Werror=stringop-overflow" } |
| 2 | // { dg-do compile } |
| 3 | |
| 4 | // PR libstdc++/117983 |
| 5 | // -Wstringop-overflow false positive for __builtin_memmove from vector::insert |
| 6 | |
| 7 | #include <vector> |
| 8 | |
| 9 | typedef std::vector<unsigned char> bytes; |
| 10 | |
| 11 | void push(bytes chunk, bytes& data) { |
| 12 | if (data.empty()) { |
| 13 | data.swap(chunk); |
| 14 | } else { |
| 15 | data.insert(data.end(), chunk.begin(), chunk.end()); |
| 16 | } |
| 17 | } |