-de- wrote:
What version of GCC are you using?
Here, 4.2.1 doesn't warns about anything..
--
Pietro Cerutti
Dear experts !
>
>
Consider the following code snippet :
>
/*============== =============== ===*/
/* void.c */
void f(int i)
{
i++;
if (i!=10)
return f(i);
}
>
int main(void)
{
f(0);
return 0;
}
/*============== =============== ===*/
>
>
gcc warns me with the following message:
>
>
-------------------------------------------
$ gcc -g -W -Wall -pedantic -o x void.c
void.c: In function "f":
void.c:5: attention : "return" with a value, in function returning void
-------------------------------------------
>
>
"return with a value" ? what a nonsense !
>
The function f returning no value (void), the instruction
return f();
isn't an error. It's equivalent to a return statement, apart from the
function call.
>
This is a compiler's bug, isn't it ?
>
>
Consider the following code snippet :
>
/*============== =============== ===*/
/* void.c */
void f(int i)
{
i++;
if (i!=10)
return f(i);
}
>
int main(void)
{
f(0);
return 0;
}
/*============== =============== ===*/
>
>
gcc warns me with the following message:
>
>
-------------------------------------------
$ gcc -g -W -Wall -pedantic -o x void.c
void.c: In function "f":
void.c:5: attention : "return" with a value, in function returning void
-------------------------------------------
>
>
"return with a value" ? what a nonsense !
>
The function f returning no value (void), the instruction
return f();
isn't an error. It's equivalent to a return statement, apart from the
function call.
>
This is a compiler's bug, isn't it ?
Here, 4.2.1 doesn't warns about anything..
>
Thanks.
Thanks.
--
Pietro Cerutti