public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107677] New: -Warray-bounds: unclear what exactly it's meant to detect
@ 2022-11-14 14:16 carlosgalvezp at gmail dot com
  2022-11-14 17:42 ` [Bug middle-end/107677] " mpolacek at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: carlosgalvezp at gmail dot com @ 2022-11-14 14:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107677
           Summary: -Warray-bounds: unclear what exactly it's meant to
                    detect
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: carlosgalvezp at gmail dot com
  Target Milestone: ---

Hi,

I have a hard time understanding -Warray-bounds. The documentation says:

"It warns about subscripts to arrays that are always out of bounds"

And yet, none of the hits of the warning are caught by sanitizer, nor by
valgrind, nor by Clang. So how can it be that they "always" are out of bounds?
Surely they should have been caught by some other tool, if it were so obvious?

Some of the warnings go away if I "assert" that the subscript index is smaller
than the size of the array, even if the assertion is not needed. Is GCC warning
about "maybe" out of bounds cases, instead of "real" cases? 

Lastly, I find the stacktrace very confusing. It simply says "array subscript X
is out of bounds". Where does this X come from? Is it real (and if so, where in
the code is the number X defined?), or is it "a possibility" that may or may
not happen based on runtime input?

Thanks!

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

end of thread, other threads:[~2022-11-29 13:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 14:16 [Bug c++/107677] New: -Warray-bounds: unclear what exactly it's meant to detect carlosgalvezp at gmail dot com
2022-11-14 17:42 ` [Bug middle-end/107677] " mpolacek at gcc dot gnu.org
2022-11-14 18:50 ` carlosgalvezp at gmail dot com
2022-11-15 12:41 ` carlosgalvezp at gmail dot com
2022-11-15 12:51 ` pinskia at gcc dot gnu.org
2022-11-15 13:14 ` carlosgalvezp at gmail dot com
2022-11-29 13:29 ` rguenth 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).