does std::runtime_error copy the string passed in the constructor?

c++, exception

Solution

`std::exception` (which `std::runtime_error` inherits from) must make a copy of the message, even if that's not called out in the standard explicitly (that I can find). There's no reason for the `exception` class to expect that the source of the `what()` message will outlive it in the general case.

Problem

I wonder if this line creates a dangling pointer: ``` string arg="derp"; throw std::runtime_error("Unknown argument "+arg); ``` Does `std::runtime_error` copy the `string`, or does it store the reference?

Original source