This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [PATCH] Fix PR gdb/290
- From: Joe Buck <jbuck at synopsys dot COM>
- To: schwab at suse dot de (Andreas Schwab)
- Cc: jbuck at synopsys dot COM (Joe Buck),ac131313 at cygnus dot com (Andrew Cagney), kettenis at chello dot nl,gcc at gcc dot gnu dot org, gdb-patches at sources dot redhat dot com
- Date: Sat, 9 Feb 2002 17:38:59 -0800 (PST)
- Subject: Re: [PATCH] Fix PR gdb/290
> Joe Buck <jbuck@synopsys.COM> writes:
>
> |> For C89, I don't think it's legal though it may be reasonable to accept
> |> as an extension; I don't know about C99.
>
> The C99 standard is quite clear about this:
>
> 6.8.6.4[#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.
OK, then this can only be done in C++. Any C code should avoid it.
for
void foo();
void bar() { return foo();}
(which is legal C++)
I've just checked, and gcc 2.95.2 and 3.0.3 reject this type of C code
iff -ansi -pedantic is specified. By default they accept it. Anyone
developing code that must compile with many compilers probably should
be using -pedantic.