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

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jul 17 09:10:12 GMT 2024


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

--- Comment #69 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Church from comment #68)
> I do agree that "(void)" is very idiomatic, and something like a [[discard]]
> statement attribute (which would silence warnings for both
> __attribute__((wur)) and [[nodiscard]]) would make the intent clearer. 
> Perhaps something to suggest for a future version of the C standard?

Maybe you want:

     [[maybe_unused]] auto _ = foo();

This is already in C23.


More information about the Gcc-bugs mailing list