public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/106297] [12/13 Regression] stringop-overflow misbehaviour on atomic since r12-4725-g88b504b7a8c5affb
Date: Thu, 28 Jul 2022 15:28:02 +0000	[thread overview]
Message-ID: <bug-106297-4-fnFriQKFfT@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106297-4@http.gcc.gnu.org/bugzilla/>

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |12.1.0, 13.0
             Blocks|                            |88443
           Keywords|                            |missed-optimization

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
There have been other reports of false positives due to the same issue (e.g.,
some or all of pr65461, pr92539, pr92955, pr95140, and pr96447).  Since the
unrolling pass uses the invalid access to decide to unroll the loop maybe it
could insert the __builtin_unreachable() call before it (or instead of it)
rather than after it.  That way the bad access would get eliminated and the
warning avoided.  Or, it could, in addition to inserting the
__builtin_unreachable() call after it, also suppress the access warning for the
bad statement.  Alternatively, these problems could be worked around in the
warning code by suppressing it in basic blocks that terminate by a call to
unreachable.  But this would cause false negatives where the unreachable call
is added after real problems in the user's source).

Until this is solved in GCC it can be dealt with in user code by asserting the
loop doesn't iterate more times than there are elements in the array.  In the
test case in comment #5 that might look like so:

  if (n >= sizeof s / sizeof *s)
    __builtin_unreachable ();


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
[Bug 88443] [meta-bug] bogus/missing -Wstringop-overflow warnings

  parent reply	other threads:[~2022-07-28 15:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14 14:05 [Bug c/106297] New: stringop-overflow misbehaviour on atomic chipitsine at gmail dot com
2022-07-14 16:05 ` [Bug tree-optimization/106297] " pinskia at gcc dot gnu.org
2022-07-15  2:33 ` chipitsine at gmail dot com
2022-07-15  8:05 ` [Bug tree-optimization/106297] [12/13 Regression] stringop-overflow misbehaviour on atomic since r12-4725-g88b504b7a8c5affb marxin at gcc dot gnu.org
2022-07-15  8:05 ` marxin at gcc dot gnu.org
2022-07-18  7:27 ` rguenth at gcc dot gnu.org
2022-07-25 15:03 ` rguenth at gcc dot gnu.org
2022-07-28 14:33 ` jakub at gcc dot gnu.org
2022-07-28 15:28 ` msebor at gcc dot gnu.org [this message]
2023-05-08 12:25 ` [Bug tree-optimization/106297] [12/13/14 " rguenth at gcc dot gnu.org

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-106297-4-fnFriQKFfT@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).