I'd say it's a bug in your code. The return value from
std::string::c_str() is used after the temporary is destroyed.
I'm kind of surprised that the snippet above compiles; I wouldn't
expect a compiler to perform an implicit conversion from a string
literal to a std::string. Is that with MSVC?