The standard states that rvalue reference binding should be illegal: Catch By Rvalue Reference , but I have the following code:
#include <string>
#include <iostream>
using namespace std;
int main(){
try {
throw string("test");
} catch (string && s) {
cout << s << endl;
}
return 0;
}
It compiles successfully without warning with the option -Wall. How does this happen?
I use gcc version 4.6.3 20120306 (Red Hat 4.6.3-2) (GCC)
source
share