public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wschmidt at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/101830] New: Incorrect error messages beginning with r12-2591 (backward jump threader)
Date: Mon, 09 Aug 2021 15:54:43 +0000	[thread overview]
Message-ID: <bug-101830-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 101830
           Summary: Incorrect error messages beginning with r12-2591
                    (backward jump threader)
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wschmidt at gcc dot gnu.org
  Target Milestone: ---

I've been adding some code to the rs6000 back end that hasn't yet been part of
the build.  As I got ready to commit the patch to start building the code, I
found that it has recently stopped building due to bogus error messages.  These
started with r12-2591 (new backward jump threader) but is presumably also
related to the new pass for array bounds checking.

$ $GCC_INSTALL/bin/g++ $GCC_SRC/gcc/config/rs6000/rs6000-gen-builtins.c -c -O2
-Wall -Werror
/home/wschmidt/newgcc/gcc/config/rs6000/rs6000-gen-builtins.c: In function 'int
match_bracketed_pair(typeinfo*, char, char, restriction)':
/home/wschmidt/newgcc/gcc/config/rs6000/rs6000-gen-builtins.c:824:22: error:
array subscript 1024 is above array bounds of 'char [1024]'
[-Werror=array-bounds]
  824 |       if (linebuf[pos] != ',')
      |           ~~~~~~~~~~~^
/home/wschmidt/newgcc/gcc/config/rs6000/rs6000-gen-builtins.c:186:13: note:
while referencing 'linebuf'
  186 | static char linebuf[LINELEN];
      |             ^~~~~~~
/home/wschmidt/newgcc/gcc/config/rs6000/rs6000-gen-builtins.c:843:22: error:
array subscript 1024 is above array bounds of 'char [1024]'
[-Werror=array-bounds]
  843 |       if (linebuf[pos] != close)
      |           ~~~~~~~~~~~^
/home/wschmidt/newgcc/gcc/config/rs6000/rs6000-gen-builtins.c:186:13: note:
while referencing 'linebuf'
  186 | static char linebuf[LINELEN];
      |             ^~~~~~~

...and many more, all referencing uses of linebuf[pos].

There are several problems with these messages:

(1) linebuf and pos are global variables, and the compiler cannot tell whether
or not there are problems with array bounds accesses here. Indeed, pos is only
incremented by a function called "safe_inc_pos" that ensures we *don't* ever
access beyond the end of linebuf.

(2) The error message is far too certain of itself!  It says that we have
definitely addressed out of bounds when that is certainly not known to be true.

(3) Some uses of linebuf[pos] are flagged, and others are not, often within the
same function.

You can reproduce this as above with the code that is upstream in trunk.

This is holding up committing some approved patches, so I appreciate anything
you can do to sort this out.

             reply	other threads:[~2021-08-09 15:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09 15:54 wschmidt at gcc dot gnu.org [this message]
2021-08-09 15:57 ` [Bug tree-optimization/101830] " wschmidt at gcc dot gnu.org
2021-08-09 17:55 ` pinskia at gcc dot gnu.org
2021-08-09 19:46 ` [Bug tree-optimization/101830] [12 Regression] " wschmidt at gcc dot gnu.org
2021-08-10  1:30 ` segher at gcc dot gnu.org
2021-08-10 12:33 ` wschmidt at gcc dot gnu.org
2021-08-12 17:35 ` msebor at gcc dot gnu.org
2021-08-12 17:47 ` wschmidt at gcc dot gnu.org
2021-08-12 17:50 ` msebor at gcc dot gnu.org
2021-08-12 18:06 ` wschmidt at gcc dot gnu.org
2021-08-12 18:44 ` wschmidt at gcc dot gnu.org
2021-08-12 19:54 ` wschmidt at gcc dot gnu.org
2021-08-12 20:15 ` msebor at gcc dot gnu.org
2021-08-12 20:39 ` wschmidt at gcc dot gnu.org
2021-08-23 21:00 ` [Bug target/101830] " cvs-commit 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-101830-4@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).