[Bug c/66425] (void) cast doesn't suppress __attribute__((warn_unused_result))
uecker at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jul 17 08:15:11 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
--- Comment #67 from uecker at gcc dot gnu.org ---
(In reply to Andrew Church from comment #66)
> (In reply to Andrew Church from comment #65)
> > As one of the advocates for this behavior, it stems (at least in my case)
> > from pre-C23 code in which [[attribute]] syntax was not available. If
> > [[nodiscard]] suppresses the warning, I'd accept that as a solution.
>
> Premature reply (apologies) - I somehow gave myself the impression that
> [[nodiscard]] could be put at the place of use. Since it's something the
> library writer has to do, I think this is still not enough from the library
> user's point of view.
I agree that this is an argument for having a compiler switch.
But also the library could switch to "discard" or add a condition that the
lets the user of the library choose it.
As a last resort, on the compiler side one can already use a pragma to turn off
the
warning at a specific point.
So I am a bit unsure about whether the flag is worth having....
More information about the Gcc-bugs
mailing list