GCC is correct. From item 4 of 3.10 Lvalues โโand rvalues โโ[basic.lval]:
The prvalues โโclass can have cv-quali-fi types; non-class prvalues โโalways have cv-unqualified types. [...]
A function call, such as fun_ci() , is actually prvalue *, and as such is of type int , not const int . int&& better than const int&& , and should be selected using overload resolution.
*: it was usually said that top-level cv qualifiers are ignored for non-class return types.
Luc danton
source share