On 31 October 2006 20:21, 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?
>
> Regards, Igor
Yep. PR 5678. This patch worked for me: apologies in advance for
line-wrapping it.
===================================================================
RCS file: /sources/repository/external_source/gnu/gcc-3.3.3/gcc/c-typeck.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- external_source/gnu/gcc-3.3.3/gcc/c-typeck.c 2004/03/26 13:22:21
1.1
+++ external_source/gnu/gcc-3.3.3/gcc/c-typeck.c 2006/04/23 15:25:06
1.2
@@ -7068,8 +7068,12 @@
else if (valtype == 0 || TREE_CODE (valtype) == VOID_TYPE)
{
current_function_returns_null = 1;
+ /* [ARTIMI_LOCAL] Fix PR40 (gcc PR5678) by warning without -pedantic,
+ even if attempting to 'return a void'. */
if (pedantic || TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
pedwarn ("`return' with a value, in function returning void");
+ else if (warn_return_type)
+ warning ("`return' with a value, in function returning void");
}
else
{
cheers,
DaveK
--
Can't think of a witty .sigline today....