void function cannot return value
Why? -- this is example code. the actual source is the Axis2C 1.0 package. Is there a way to override this error? I don't think gcc complains.
hello.c
void goo() {
1;
return;
}
void foo() {
return goo();
}
int main(int argc, char** argv) {
foo();
}
[326 byte] By [
weinharda] at [2007-11-27 7:14:58]

# 1
gcc accepts, although it is prohibited by the C language standard.
it produces a reasonable diagnostics only with -pedantic.
=============================================
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.
=============================================
I think, that since the semantics is clear the C compiler folks could
fix the compiler to issue a warning here.
This is now bug 6568828.
It will become visible on bugs.sun.com in a couple of days.
horsha at 2007-7-12 19:05:10 >
