public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "romato.san1337 at gmail dot com" <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: Wed, 09 Aug 2023 22:33:21 +0000	[thread overview]
Message-ID: <bug-66425-4-HKKncyYtmm@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

Roman Krotov <romato.san1337 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |romato.san1337 at gmail dot com

--- Comment #54 from Roman Krotov <romato.san1337 at gmail dot com> ---
I'm also very frustrated about this behavior, but I'm not asking to **change**
it. I see your point and, although I think it's severely outdated now, I
respect your decision.

Instead I'm offering a compromise, or to better describe it, a win-win
solution.
What about introducing something like `-Wno-void-unused`, which would only
disable the warnings for the (void) casted calls?

And I'm not asking to do it for me, or some other random dudes; do it for
systemd, they are also very frustrated about this:
https://github.com/systemd/systemd/blob/5a96b32dead5132ba37a8b968c59101c2aac8d23/meson.build#L400

That's because they use (void) casts very frequently:
https://github.com/search?q=repo%3Asystemd%2Fsystemd+language%3AC+%22%28void%29%22&type=code

You can probably say they are in the wrong by doing the bad practice and should
do a macro instead.
And you may be right. I really appreciate your commitment to teach people good
practices, but **suggesting** them (by setting the default behavior which
**recommends** the programmers to use these practices) should be enough.
I don't think it's a good idea to **force** people to use them, by either
spamming them with warnings (useless to them, because they already made a
decision) or making them disable such warnings altogether, which could lead
them to miss a bug where they forgot to use a value of a function (which they
didn't cast with void).

You may say it's their fault, but let me ask you a question, who is winning
from the current situation? Certainly, not you, because you didn't convince
them to change, instead you just made them not listen to you, see also
julia-language and mpv:
https://github.com/search?q=%22-Wno-unused-result%22&type=code

And certainly, not them, because of the bug-risk I typed above, which is really
unfortunate for such a big and widely-used project as systemd.
Also, making them switch to clang (or drop gcc support) would be really bad,
because nothing hurts FOSS and frustrates me in a project more than a
permissive license. Eww..

Sorry, if I was a little bit harsh there, I really appreciate your contribution
to FOSS and Linux development, and I would never switch to clang.
Just, please note, that, again, I'm begging you to just implement a non-default
switch that would make everyone's lives easier.

Why "everyone's"? You see,

If a new programmer encounters this "problem", they would think it's just a
"gcc bug", because "clang works as expected" (and also the mentioned projects
wrote like this in a comment), so they just disable the warnings altogether.
Nobody won, especially the programmer.
Now consider the situation where you implemented the switch, but wrote, for
example, in the manpage just that "It's not recommended". Now they will be
curious why, so they will try to find an answer, and the search will probably
lead them to the gnu.org page which has the answer.

See, how even though you might think you gave the ability to write a bad code,
in reality you would give the exact point why not to use (void)? (Which they
really need because other compilers/linters are trying to convince them
otherwise.)
Come on, at least please admit that the situation described above would still
be better than today's.

If you will find at least some of my points somewhat reasonable, please share
my comment with the people that can help bring this improvement to life.

  parent reply	other threads:[~2023-08-09 22:33 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
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 [this message]
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-HKKncyYtmm@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: link
Be 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).