Consider this piece of code:
int a[]{0};
auto&& ref1 = std::move(a)[0];
auto&& ref2 = a[0];
If I understand the C++ standard (C++17) correctly, ref1
's type is int&&
while ref2
's type is int&
and that is the way it works in clang. However, in gcc and msvc both ref1
and ref2
are lvalue references.
Could somebody explain to me which behaviour (and why) is correct? Whichever option is the right one it seems that at least one of the compilers I mentioned has a bug.