This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/66425] (void) cast doesn't suppress __attribute__((warn_unused_result))
- From: "lucas.de.marchi at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 11 Jun 2015 15:08:29 +0000
- Subject: [Bug c/66425] (void) cast doesn't suppress __attribute__((warn_unused_result))
- Auto-submitted: auto-generated
- References: <bug-66425-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
--- Comment #15 from Lucas De Marchi <lucas.de.marchi at gmail dot com> ---
(In reply to Manuel LÃpez-IbÃÃez from comment #14)
> (In reply to Filipe Brandenburger from comment #12)
> > Can I have this issue reopened please?
>
> If that makes you happy...
>
> > Ok, how can we assign this bug to the appropriate team then?
>
> It doesn't work like that. Individual contributors will work on things that
> they find interesting or get paid to fix.
Rusty, who opened this issue, seemed inclined to prepare such a patch.
> > I can't really think of a situation in the Linux kernel source code where
> > I'd find a __must_check function with a void cast, exactly for that reason,
> > right now it would generate a warning.
>
> The users of _wur added _wur to a function expecting that any use of this
> function that does not assign the result will get a warning, even if there
> is a cast to void. Not warning for a cast to void breaks that expectation.
As I said, the people who add the attribute may not be the same people who use
the interface with that attribute. I myself when writing libraries use the
_wur to give my users a warning if they are ignoring the return value. However
they have all the rights to ignore it. Be it simply by not using
-Wunused-result, hacking a macro to ignore the result or use the de facto
standard to cast to void. IMO the latter is the best one since there might be
1 particular case in the entire codebase in which ignoring the return makes
sense.