[Bug c/66425] (void) cast doesn't suppress __attribute__((warn_unused_result))

segher at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jul 17 13:30:44 GMT 2024


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425

--- Comment #72 from Segher Boessenkool <segher at gcc dot gnu.org> ---
The correct way to not get the warning about unused results, is to _do_ use
the function return value, of course, as I explained in #c18 already.

Like:

if (foo()) {
  /* The return value of foo can be ignored here because X and Y.  */
}

You *always* should explain why you can ignore it here (not just *that* you
can, that's not an explanation, that's merely a statement), anyway, so this
gives a nicely readable flow.


More information about the Gcc-bugs mailing list