GCC incorrectly handles name lookup within decltypes in locations such as the following: struct{int x;}x; int main(){ x.decltype(x)::x=42; } Here, the x in decltype(x) should refer to the structure x and not the member x. GCC however decides to do member lookup same as it would outside of decltype and finds the member x, which then results in GCC emitting an error because of trying to access a member named x in the type int. Clang and MSVC both accept this code.
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1787r6.html
(In reply to Andrew Pinski from comment #1) > https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1787r6.html That is gcc does not currently implements this paper.