This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Why is this diagnostic only reported with -pedantic?
Tom Schutter <tom@platte.com> writes:
> 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()).
But the value returned is void, and C++ show that this is a quite natural
extension. (The reason why this is allowed in C++ is of course not
applicable to C.)
> It's not that something can go wrong, its just the program is not doing
> what the programmer expects.
It's returning the value of the expression. I don't see any contradiction
between the expectation and the behaviour.
> Nothing goes wrong when there is unreachable code, but gcc still emits a
> warning when it detects unreachable code.
If you have unreachable code then very much can go wrong.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."