gcc/testsuite/g++.dg/torture/pr60750.C
raw| 1 | // { dg-do run } |
| 2 | // { dg-options "-std=c++11" } |
| 3 | // { dg-skip-if "requires hosted libstdc++ for string" { ! hostedlib } } |
| 4 | |
| 5 | #include <string> |
| 6 | #include <stdexcept> |
| 7 | |
| 8 | const std::string err_prefix = "Problem: "; |
| 9 | void thrower (std::string msg) |
| 10 | { |
| 11 | throw std::runtime_error(err_prefix + std::move(msg)); |
| 12 | } |
| 13 | |
| 14 | int main(int argc, char **argv) |
| 15 | { |
| 16 | try { |
| 17 | std::string base = "hello"; |
| 18 | thrower(std::move(base)); |
| 19 | } catch (const std::runtime_error &e) { |
| 20 | } |
| 21 | return 0; |
| 22 | } |