public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "eggert at cs dot ucla.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/109914] --suggest-attribute=pure misdiagnoses static functions
Date: Sun, 26 May 2024 17:47:34 +0000	[thread overview]
Message-ID: <bug-109914-4-jNMpx5v9iI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109914-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from Paul Eggert <eggert at cs dot ucla.edu> ---
(In reply to Jan Hubicka from comment #5)
> yes, however both const and pure attributes allows compiler to also
> remove the call if return value is unused.  So here finiteness matters.
Thanks for mentioning that. I now see that there are other differences between
const/pure and unsequenced/reproducible: see N2956
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm#gcc>, which says
that the GCC notions are stricter than the corresponding C23 notions. N2956
doesn't mention finiteness as one of the strictness differences, though, I
guess because the C23 standardizers didn't notice that part of the GCC
documentation.

So my idea that "[[reproducible]] and __attribute__((pure)) are supposed to be
the same thing" is incorrect. Similarly, [[unsequenced]] and
__attribute__((const) are not the same thing. Oh well. We may need to change
Gnulib because of these discrepancies.

>> I agree with Bruno's main point that none of this stuff should matter for
>> static functions. --suggest-attribute=* warnings are useless chatter for
>> static functions.
> It helps the compiler to solve the halting problem.
This isn't a halting-problem situation. If GCC cannot deduce that a static
function halts, and if no calls to that function discard the return value (so
the optimization you mentioned can't apply), then suggesting to the developer
to add __attribute__((pure)) merely wastes developers' time, and developers
either disable the warning or ignore it, neither of which is good. So Bruno's
suggestion of suppressing the false positive for his test case still seems to
be a good one.

      parent reply	other threads:[~2024-05-26 17:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-20  9:44 [Bug ipa/109914] New: " bruno at clisp dot org
2023-05-20 14:47 ` [Bug ipa/109914] " pinskia at gcc dot gnu.org
2023-05-28 20:15 ` hubicka at gcc dot gnu.org
2023-05-28 22:16 ` bruno at clisp dot org
2024-05-25 18:14 ` eggert at cs dot ucla.edu
2024-05-26 12:21 ` hubicka at ucw dot cz
2024-05-26 17:47 ` eggert at cs dot ucla.edu [this message]

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-109914-4-jNMpx5v9iI@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).