On 3/06/2016 20:04, Werner Erasmus wrote:
I've recently written some code on Linux where I had to adapt a filesystem::path object to string. I noticed that the return value was of type [const std::string&], and used the same return value in my getter that exposed the underlying string. Moving over to windows, I had strange crashes (undefined behaviour) as result of the type under windows being converted to [std::string]. The reason for the "undefined behaviour" took me a while to figure out.
While I don't disagree with anything that you said in the unquoted parts of your message, the compiler should have generated a warning ("returning temporary by reference" or similar) in your getter method when compiling on Windows. The problem should have been discoverable this way.