This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/66425] (void) cast doesn't suppress __attribute__((warn_unused_result))
- From: "filbranden at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 20 Aug 2015 06:05:21 +0000
- Subject: [Bug c/66425] (void) cast doesn't suppress __attribute__((warn_unused_result))
- Auto-submitted: auto-generated
- References: <bug-66425-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
--- Comment #22 from Filipe Brandenburger <filbranden at google dot com> ---
(In reply to Jan Engelhardt from comment #20)
> Seems like the short route is to add a new attribute
> ((warn_unused_result_with_void_cancelling)) that exhibits the "desired"
> behavior of (void) cancelling the warning, and then make glibc use that.
> Simple, no?
I'd rather see ((warn_unused_result_without_void_cancelling)).
Or, better yet, add both in and add a command-line flag to allow
((warn_unused_result)) to use one or the other.
I still don't see the point of preventing (void) from cancelling it since you
can just store the result on an otherwise unused "discard" variable, I mean, if
the programmer *really* wants to ignore the result, they can do it in many
ways, ((warn_unused_result)) is to prevent programming mistakes where the
programmer *meant* to look at the results but mistakenly forgot it...
I also fail to see what else a void cast can mean other than explicitly
indicating that the programmer *knows* the function returns a non-empty value
but decided to ignore it...
Anyways, let's not go on that rant again... If you get to implement the new
attribute that would be awesome!
Cheers,
Filipe