public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/101830] New: Incorrect error messages beginning with r12-2591 (backward jump threader)
@ 2021-08-09 15:54 wschmidt at gcc dot gnu.org
  2021-08-09 15:57 ` [Bug tree-optimization/101830] " wschmidt at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2021-08-09 15:54 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-08-23 21:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09 15:54 [Bug tree-optimization/101830] New: Incorrect error messages beginning with r12-2591 (backward jump threader) wschmidt at gcc dot gnu.org
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

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).