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

--- Comment #81 from rusty at rustcorp dot com.au ---
(In reply to Jakub Jelinek from comment #76)
> (void) casts not quieting the warning was an intentional request when the
> warning has been added, I really don't think it is a good idea to change
> that.

Indeed, but it wasn't called "dont_ignore_realloc", it seemed far more generic,
and there wasn't an alternative for a long time.  Once GLIBC started using it
(such as for write()), it became an ongoing thorn in the side of many users :(
The escalation continued with GNUlib implementing a suppression macro.

(I'm not picking on the GNU project fighting itself here, but it's a clear case
showing the problem).

> Perhaps you can ask
> glibc to recategorize some of the declarations to use [[nodiscard]] instead
> of __attribute__((__warn_unused_result__))
...
> E.g. ignoring return value of realloc is pretty much always a bad idea and
> just (void) realloc (...); is something that shouldn't be supported.

Indeed!  I think this is the solution (once [[nodiscard]] is old enough for
projects to migrate).  Not many function returns are as clearly required as
realloc...

Reply via email to