http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46766
Summary: Type 'void' is treated differently if used as return
value or as parameter
Product: gcc
Version: 4.5.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
It is valid to return a void-function, or cast a variable to void, from a
void-function.
This makes some sense, in particular in C++ since we might have a template, and
we would like to put 'void' as type in this C++ template.
But then maybe it should also be allowed to put 'void' as inparameter to a
void-function, but then compiler warns about too many arguments.
void.c: In function ‘main’:
void.c:16: error: too many arguments to function ‘f1’
void.c:17: error: too many arguments to function ‘f2’
Somehow it would be more 'aligned' to have function-return-values and
function-in-parameters work the same way, so that template-alike-constructions,
or similar pure C macro/preprocessor constructions, could work the same
perhaps?
void f1(void)
{
return (void)0; //OK
}
void f2(void)
{
return f1(); //OK
}
int main(void)
{
f1(); //OK
f2(); //OK
f1((void)0); //ERROR
f2(f1()); //ERROR
return 0;
}