[cfe-dev] Rejecting "void f(const void);"?

Eli Friedman eli.friedman at gmail.com
Fri Feb 15 00:33:22 PST 2008

In all of clang, gcc, and comeau, some sort of error is given for a
declaration like "void f(const void);".  However, as far as I can
tell, it's perfectly valid code (although mostly worthless, since the
declared function can't be called or defined).  Is there some reason
for rejecting this that I'm missing?

Here are a few similar tests: "const void f(void)", "const void
f(void) {}", "const void f(void); void g(void) {f();}".  The first
test is legal code, the second and third are not, as far as I can
tell.  clang incorrectly allows the second and third tests, gcc
incorrectly allows the third test, and comeau incorrectly rejects the
first test.  (Although note that clang doesn't have any checks for
incomplete return types yet.)


More information about the cfe-dev mailing list