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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With