One VS2010 bug ? Allowing binding non-const reference to rvalue WITHOUT EVEN a warning?
string foo() { return "hello"; } int main() { //below should be illegal for binding a non-const (lvalue) reference to a rvalue string& tem = foo(); //below should be the correct one as only const reference can be bind to rvalue(most important const) const string& constTem = foo(); } GCC is the good one to give a compile error : invalid initialization of non-const reference of type std::string& from a temporary of type std::string VS2008 is not too bad as at least it gives a compile warning : warning C4239: nonstandard extension used : 'initializing' : conversion from std::string to std::string