On Tue, 20 May 2008 23:27:18 +0200, Pietro Cerutti wrote:
> Harald van Dijk wrote:
>> 6.8.6.4 The return statement
>> Constraints
>> 1 A return statement with an expression shall not appear in a function
>> whose return type is void. A return statement without an expression
>> shall only appear in a function whose return type is void.
>>
>> This disallows
>>
>> void f(void);
>> void g(void) {
>> return f();
>> }
>>
>> because while f() can be argued not to have a value, it is still an
>> expression.
>
> Would you like to see my answer to Keith and try to elaborate that?
You already have your answer, but here's another approach:
The syntax of the return statement is:
jump-statement:
[...]
return expression[opt] ;
This means there are two forms of the return statement. They are:
return ;
return expression ;
If f() is an expression, return f(); violates 6.8.6.4p1. If f() is not an
expression, return f(); is a syntax error. So it doesn't really matter,
either way, the compiler must complain.