Consider the following demonstrative program.
#include <iostream>
namespace N
{
struct A
{
static int n;
};
A A;
}
int N::A::n = 10;
int main()
{
std::cout << N::A::n << '\n';
std::cout << N::decltype( N::A )::n << '\n';
return 0;
}
The program compiles successfully using gcc 8.3 at for example www.ideone.com.
However if to run this program using MS VS 2019 then the compiler issues an error relative to the record decltype( N::A )
in the nested-name-specifier. If to remove preceding name N::
then the program compiles successfully.
Is it a bug of the MS VS compiler or is the nested-name-specifier written incorrectly?
A decltype-specifier can never appear except at the beginning of a nested-name-specifier. After all, it designates a specific type, and no name lookup is necessary afterwards to interpret it. GCC is wrong to accept the code: by experimentation, it seems to just ignore any preceding components after checking that they exist.