Is the correct return type deduced with decltype(auto)?

Viewed 189
decltype(auto) func(int&& n)
{
    return (n);
}

clang 12.0.1 accepts this code, but gcc 11.2.1 rejects it with:

error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int' 

gcc seems to use return type int &&, but with n inside parenthesis, is that correct?

godbolt demo

0 Answers
Related