Which compiler is correct? (Hopefully the answer isn't 'both' like it was the last time clang accepted code and gcc didn't...) If gcc is correct and there is a bug in clang 3.1->3.3, then how else would you recommend achieving this? (My actual situation is different and I can fix it without this trick, but I am still curious)
Purely at a guess I'd say that it shouldn't compile because it's impossible to pass literally nothing... as something.
I'm afraid I'm not a wizard in such standards though and I suppose I'm just rather curious to see the answers too... I'll see if I can sniff out some info.
So far the best I have is this from the GCC standards (rephrased)
A value of type void is really not a value at all, so it can't appear in any context where an actual value is required.
Such contexts include the following:
the right side of an assignment
an argument of a function
the controlling expression of an if, for, or while statement.
So I imaging that GCC compiler attempts to allocate memory for every value passed to the ... but as void has no value it is unable to do so and hence the behavior is undefined and must be prohibited.
The CLang compilers must just evaluate void as being unable to locate a space in physical memory and completely ignore any variables passed to ..., (Again most of this is assumption so please don't scream if I'm wrong :D )
test.cc(13): error: incomplete type is not allowed
int x = g(f());
^
Oracle said
"test.cc", line 13: Error: A value of type void is not allowed.
IBM said
"test.cc", line 13.16: 1540-0216 (S) An expression of type "void" cannot be converted to type "...".
"test.cc", line 13.16: 1540-1205 (I) The error occurred while converting to parameter 1 of "g(...)".
I think the relevant chapter is §5.2.2[expr.call]/7
After these conversions, if the argument does not have arithmetic, enumeration, pointer, pointer to member, or class type, the program is ill-formed.