public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/66425] (void) cast doesn't suppress __attribute__((warn_unused_result)) Date: Sun, 23 Apr 2023 22:03:47 +0000 [thread overview] Message-ID: <bug-66425-4-o1Q05LXIi5@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-66425-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 --- Comment #45 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Church from comment #44) > (In reply to Segher Boessenkool from comment #43) > > That is not the consensus, no. "Consensus" does not mean doing what the > > unthinking masses shout. > > Merriam-Webster disagrees: > con.sen.sus > 1 a: general agreement : UNANIMITY > b: the judgment arrived at by most of those concerned But there is no general agreement at all. If clang behavior agreed with gcc, then there would be consensus here. In fact gcc behavior is older than clang behavior makes this even more difficult and even points out that if clang said it implemented a compatible extension, it did not. > > I specifically clarified that with "wider" to indicate the larger group of > "C compiler users", as opposed to what you seem to mean, "C compiler > developers". And in whatever sense you choose to regard them, the judgment > arrived at by most C compiler users does seem to be "cast to void should > suppress a warning about a discarded value", as I described above. > There is still no general consensus really. Just that the folks who want behavior difference is loud while the ones who are happy with the current behavior are quiet because they don't need to tell their thoughts on it. > > So allowing casts to void > > to suppress this warning means the warning becomes less useful, and people > > will write worse code. That is not something GCC should encourage IMO. > > You seem to think that making the warning harder to work around will > encourage programmers to change their code to fix the warning. In reality, > they are more likely to either (1) disable the warning entirely or (2) > disregard warnings in general, both of which result in considerably worse > code - the situation you say you are trying to avoid. Thus my suggestion to > follow the principle of least surprise and allow a void cast to disable the > warning by default. You are basically saying all warnings will be ignored which is true. Even ones with no false positives are ignored. Using a void cast makes life too easy to ignore this behavior. If the api user wants to ignore the return values while the api developer tells you should not, then really the api user will have bugs. This is why the warning is there. Now api developers have known to place this attribute on things that should not be placed on but that is not a compiler issue and the api user should talk with the api developer rather than try to change the compiler for their workaround.
next prev parent reply other threads:[~2023-04-23 22:03 UTC|newest] Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-06-05 0:38 [Bug c/66425] New: " rusty at rustcorp dot com.au 2015-06-05 7:21 ` [Bug c/66425] " manu at gcc dot gnu.org 2015-06-11 0:51 ` filbranden at google dot com 2015-06-11 5:39 ` pinskia at gcc dot gnu.org 2015-06-11 5:52 ` koct9i at gmail dot com 2015-06-11 5:55 ` filbranden at google dot com 2015-06-11 6:06 ` pinskia at gcc dot gnu.org 2015-06-11 6:37 ` filbranden at google dot com 2015-06-11 6:46 ` filbranden at google dot com 2015-06-11 6:49 ` lucas.de.marchi at gmail dot com 2015-06-11 8:41 ` manu at gcc dot gnu.org 2015-06-11 14:10 ` schwab@linux-m68k.org 2015-06-11 14:25 ` manu at gcc dot gnu.org 2015-06-11 15:08 ` lucas.de.marchi at gmail dot com 2015-06-11 15:49 ` joseph at codesourcery dot com 2015-06-11 16:57 ` filbranden at google dot com 2015-06-14 17:29 ` segher at gcc dot gnu.org 2015-08-20 5:35 ` rusty at rustcorp dot com.au 2015-08-20 6:05 ` filbranden at google dot com 2020-03-28 11:07 ` pskocik at gmail dot com 2021-07-27 19:33 ` ndesaulniers at google dot com 2023-04-22 21:20 ` achurch+gcc at achurch dot org 2023-04-23 7:07 ` sjames at gcc dot gnu.org 2023-04-23 7:53 ` achurch+gcc at achurch dot org 2023-04-23 20:00 ` segher at gcc dot gnu.org 2023-04-23 21:51 ` achurch+gcc at achurch dot org 2023-04-23 22:03 ` pinskia at gcc dot gnu.org [this message] 2023-04-23 23:06 ` achurch+gcc at achurch dot org 2023-04-24 6:45 ` rusty at rustcorp dot com.au 2023-04-24 8:21 ` achurch+gcc at achurch dot org 2023-04-24 8:26 ` jakub at gcc dot gnu.org 2023-04-24 8:35 ` fw at gcc dot gnu.org 2023-04-24 9:06 ` segher at gcc dot gnu.org 2023-04-24 9:18 ` jengelh at inai dot de 2023-04-24 9:41 ` achurch+gcc at achurch dot org 2023-08-09 22:33 ` romato.san1337 at gmail dot com 2023-08-09 23:09 ` ed at catmur dot uk 2023-08-10 9:23 ` muecker at gwdg dot de 2023-08-10 12:25 ` romato.san1337 at gmail dot com 2023-08-10 18:12 ` ed at catmur dot uk 2023-08-17 13:09 ` romato.san1337 at gmail dot com 2023-09-06 11:07 ` segher at gcc dot gnu.org 2023-09-06 11:51 ` achurch+gcc at achurch dot org 2024-02-14 11:32 ` groessler_christian at yahoo dot de
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-66425-4-o1Q05LXIi5@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).