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

--- Comment #83 from rusty at rustcorp dot com.au ---
> Then they shouldn't use warn_unused_result!  The documentation of that is 
> very very clear: both about what it does, and about what situations it is 
> meant for.  People who want something else should *use* something else!

1) In 2005 when this bug was reported, there was no alternative.  There still
isn't (for C, not C++).
2) Despite our best intentions, people use things in unintended ways, and it
becomes something else.  I have both sympathy for your viewpoint, and for users
caught in the middle.

Documentation says:

"This is useful for functions where not checking the result is either a
security problem or always a bug, such as ‘realloc’."

If we added __attribute__((nodiscard)) a-la C++, then this would be a good
place to recommend it for cases where you *almost* always want to consider the
result.

> The existing w_u_r is very obviously very useful though, as it is, and should 
> not be weakened in any way

It is *so* useful it gets used anywhere you want to caution the user that they
*probably* meant to check the result.  But it does not follow that making
(void) remove the warning vs a GNULib macro would not make it notably less
useful.

Reply via email to