return void from void function is allowed.

Mike Stump mrs@apple.com
Tue Oct 31 20:49:00 GMT 2006


On Oct 31, 2006, at 12:21 PM, Igor Bukanov wrote:
> GCC 4.1.2 and 4.0.3 incorrectly accepts the following program:
>
> void f();
>
> void g()
> {
>    return f();
> }
>
> No warning are issued on my Ubuntu Pentium-M box. Is it a known bug?

If you want one:

mrs $ gcc-4.2 -ansi -pedantic-errors t.c
t.c: In function 'g':
t.c:5: error: 'return' with a value, in function returning void

This is valid in C++.

And final thought, wrong mailing list...   gcc-help would have been  
better.



More information about the Gcc mailing list