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