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

Andrew Church <achurch+gcc at achurch dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |achurch+gcc at achurch dot org

--- Comment #40 from Andrew Church <achurch+gcc at achurch dot org> ---
Created attachment 54906
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54906&action=edit
POC patch to add -Wunused-result=strict

In hopes of moving this along (after having run into it for the third or fourth
time myself), here's a proof-of-concept patch against GCC 12.2.0 which adds
"-Wunused-result=strict" for the current behavior and changes "-Wunused-result"
to ignore cases in which the result is discarded by casting to void.

My rationale for changing the default behavior is that the wider community
consensus, as evidenced by things like the C++ (and C2x) [[nodiscard]]
specification, the behavior of Clang, and the balance of comments on this bug,
seems to be that casting a discarded return value to void should suppress any
warning about the discarded value; and under the principle of least surprise,
GCC should follow that consensus by default even if it also provides
alternative behaviors.

Reply via email to