This content has been marked as final. Show 1 reply
Historically, C++ compilers varied in whether they allowed a reference-to-non-const to be bound to an rvalue such as a temporary object.
Since many compilers (notably g++) allowed it in the past, Studio C++ also allowed it for compatibility.
T foo(); const T& q = foo(); // always OK T& r = foo(); // ???
With modern template uses, particularly in BOOST code, allowing code such as the marked line changed the results of function overloading and the selection of template specializations.
To allow valid code to work, we changed the default behavior of the compiler (refer to the compiler documentation) to disallow the technically invalid code. We also added an option to restore the old behavior to allow existing code to work. If you have a mix of old and new code, you need to modify the old code to make it valid.
I think we could issue a warning when actually binding a reference-to-non-const to an rvalue. Please file an RFE (request for enhancement) via your support channel if you have a support contract. If not, you can file an RFE at http://bugs.sun.com.