If you look at the grammar for *declarator*s in §8/4
you'll notice that a noptr-declarator
can be written as (ptr-declarator
), that is, it can be written as (declarator-id
), which validates declarations like the ones in the title. As matter of fact this code compiles without a problem:
#include <iostream>
struct A{ int i;};
int (x) = 100;
A (a) = {2};
int main()
{
std::cout << x << '\n';
std::cout << a.i << '\n';
}
But what is the purpose of allowing these parentheses when a pointer (to an array or to a function) is not involved in the declaration?