gcc/testsuite/g++.dg/warn/string1.C
raw| 1 | // PR c++/35652 |
| 2 | // { dg-options "-O -Wall" } |
| 3 | // { dg-skip-if "requires hosted libstdc++ for string" { ! hostedlib } } |
| 4 | |
| 5 | #include <string> |
| 6 | int test() { |
| 7 | // blank line padding, could also be code... |
| 8 | // |
| 9 | // |
| 10 | // |
| 11 | // |
| 12 | // |
| 13 | // |
| 14 | // |
| 15 | // |
| 16 | // |
| 17 | std::string s = ""; |
| 18 | s += 'x' + "y"; // { dg-warning "bounds of constant string" } |
| 19 | |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | // With -std=c++17 we get another warning deep under operator+=. |
| 24 | // { dg-prune-output __builtin_memcpy } |