GCC 4.8 with GNU STL produces bad code for std::string constructor?
问题 So a bit of C++ code: void func( const std::string& theString ) { std::string theString( theString ); theString += " more string"; std::cout << theString; } which compiles fine with GCC 4.8 and VS 2013 . From my C++ knowledge, the code is okay with a local variable theString being brought into scope which then hides theString from the function argument. At the point of theString construction, the only theString in scope is the function argument which is passed to the std::string constructor.