This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Why is this diagnostic only reported with -pedantic?
- From: Tom Schutter <tom at platte dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 09 Feb 2005 16:06:21 -0700
- Subject: Why is this diagnostic only reported with -pedantic?
- Organization: Platte River Associates, Inc.
Given this program:
static void foo(void) { return(1); }
static void bar(void) { }
static void baz(void) { return(bar()); }
int main(int argc, char * argv[]) {
baz();
return(1);
}
A compile without -pedantic gives a warning for foo(), but not for
baz():
$ gcc-3.4 foo.c
foo.c: In function `foo':
foo.c:1: warning: `return' with a value, in function returning void
A compile with -pedantic gives a warning for both functions.
$ gcc-3.4 -pedantic foo.c
foo.c: In function `foo':
foo.c:1: warning: `return' with a value, in function returning void
foo.c: In function `baz':
foo.c:3: warning: `return' with a value, in function returning void
Is there a good reason that the warning for baz() is not generated
without -pedantic? From the doc I see:
`-pedantic'
Issue all the mandatory diagnostics listed in the C standard.
Some of them are left out by default, since they trigger
frequently on harmless code.
In my opinion, the problem in baz() is just as bad as the problem in
foo().
--
Tom Schutter