Is it valid to declare a variable without a name

Viewed 61

I came across the following comment:

What is unsigned;

By looking at the declaration above I thought it is invalid. So to empirically verify this i tried the same with different compiler and to my surprise it works in some and rejected in others.

Demo

For reference the code is as follows:

int main()
{
    unsigned; //IS THIS VALID IN STANDARD C++?

}

As we can see in the linked demo, it is accepted in msvc(without any warning) and also accepted in clang(with a warning) but rejected in gcc.

My question is that is unsigned; valid according to the C++ standard ? And so which compiler(s) is right?

PS: Note that my question is about both built in types as well as class-types.

0 Answers
Related