This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why is this diagnostic only reported with -pedantic?


On Thu, 2005-02-10 at 11:21 +0100, Andreas Schwab wrote:
> Tom Schutter <tom@platte.com> writes:
> 
> > In my opinion, the problem in baz() is just as bad as the problem in
> > foo().
> 
> Why do you think so?  What can go wrong this way (apart from being less
> portable)?
> 
> Andreas.

It helps to imagine that these functions are 100 lines long instead of 1
line long.

The programmer assumes that a value is being returned by foo(), because
of the return(1).  The programmer also assumes that a value is being
returned by baz(), because of the return(bar()).

It's not that something can go wrong, its just the program is not doing
what the programmer expects.  Nothing goes wrong when there is
unreachable code, but gcc still emits a warning when it detects
unreachable code.

--
Tom Schutter



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]