This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [using gcc book] ch10.11 Certain Changes We Don't Want to Make
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: Chris Devers <cdevers at pobox dot com>
- Cc: GCC list <gcc at gcc dot gnu dot org>
- Date: Mon, 25 Aug 2003 22:24:14 -0700
- Subject: Re: [using gcc book] ch10.11 Certain Changes We Don't Want to Make
- References: <Pine.OSX.4.56.0308252345330.12109@macdaddy.local>
Chris Devers <cdevers@pobox.com> writes:
> In section 10.11, "Certain Changes We Don't Want to Make"
> we have the following paragraph:
>
> * Warning when a non-void function value is ignored.
>
> Coming as I do from a Lisp background, I balk at the idea that
> there is something dangerous about discarding a value. There
> are functions that return values which some callers may find
> useful; it makes no sense to clutter the program with a cast
> to void whenever the value isn't useful.
>
> There's just a bit more axe-grinding from the MIT alum that wrote this
> than is strictly necessary, I think :)
Agree. I'm not even sure such a warning would be rejected today, if
someone submitted a clean patch for it. I doubt we would put it into
-Wall, but having the option seems fair to me.
...
> Here's what I've got for a replacement:
>
> Think carefully before discarding values. There are functions
> that return values which some callers may find useful, but it
> makes no sense to clutter the program with a cast to void
> whenever the value isn't useful.
>
> But even that is more "preachy" than I feel is appropriate.
>
> Would anyone care to suggest improvements?
Well, the paragraph does need to justify the policy decision not to
include this feature, so:
* Warning when a non-void function value is ignored.
We feel that there are legitimate reasons to ignore function
return values, and that writing @code{(void)} before every
function call whose result is intentionally ignored makes the
program harder to read for little benefit.
zw