I recently came across this comment by @Paul Ogilvie:
"You say "To define a pointer to a structure you only need to know the structure tag". In my experience that is unnecessary. Just declare a pointer_to_some_type and the compiler will reserve space for a pointer and does type checking on assignment. Only once you want dereference the pointer and access its members, must the type fully be known."
I tried it out with:
struct foo {
int a;
struct bar* x;
};
struct bar {
int b;
};
and indeed neither GCC nor Clang doesn't throw any diagnostic, as opposed to attempt to defining an object of the respective struct without forward-declaration.
But that makes me wonder: Is this standard-compliant?
Citations from the standard are highly appreciated.