Consider the following code, compiled with the latest gcc built from sources, with the -std=c++0x flag: #include <iostream> struct S { S() {} S(S &s) { std::cout << "L-value ref" << std::endl; } S(S &&s) { std::cout << "R-value ref" << std::endl; } }; S source() { static S s; return s; } int main() { std::cout << "here 1 \n"; S s; std::cout << "here 2 \n"; S t(s); std::cout << "here 3 \n"; S u(source()); // ERROR HERE } For me, this prints: here 1 here 2 L-value ref here 3 L-value ref It should print: here 1 here 2 L-value ref here 3 R-value ref An rvalue should under no circumstance bind to a non-const lvalue reference.
This is not a bug. In the line that prints "L-value ref" where the reporter expected "R-value ref", the call to the lvalue reference constructor that we're seeing comes from inside the body of the source() function, which is returning a reference to a static variable. Since the variable is static, it is treated as an lvalue, and therefore we do a construction with S's lvalue constructor (which prints out "L-value ref"). Then, we don't actually need to perform another construction to build "u" (since we constructed the result of the call to source() in place), so there is no "R-value ref" at the end of the output/