There are at least two places in C++ standard that prohibit defining objects with incomplete types (http://eel.is/c++draft/basic.def#5, http://eel.is/c++draft/basic.types#5). However, providing non-defining declarations for objects of incomplete type is generally allowed in C++. And I don't seem to be able to pinpoint the specific part that would prohibit declaring incomplete "objects" of void
type in that fashion. (Granted, void
is not an object type in C++, but neither are reference types, for one example.) So, is this
extern void a;
really ill-formed in C++?
In C providing non-defining declarations for void
objects (as shown above) is allowed and both GCC and Clang accept the above in C code (definitions are not allowed, of course). But in C++ code both compilers issue errors for such declarations. Which part of the standard makes them to do so?
[basic.fundamental]
lists possible uses of void
type (http://eel.is/c++draft/basic.types#basic.fundamental-13) but it does not appear to be intended as a complete list.