public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/105420] New: Bogus -Warray-bounds with non-compile time-constant variable
@ 2022-04-28 13:21 byteslice at airmail dot cc
  2022-04-29  6:26 ` [Bug tree-optimization/105420] " rguenth at gcc dot gnu.org
  2022-04-29 11:42 ` byteslice at airmail dot cc
  0 siblings, 2 replies; 3+ messages in thread
From: byteslice at airmail dot cc @ 2022-04-28 13:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105420
           Summary: Bogus -Warray-bounds with non-compile time-constant
                    variable
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: byteslice at airmail dot cc
  Target Milestone: ---

Created attachment 52894
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52894&action=edit
Reduced example

On gcc 12.0.1 20220413 (Fedora 36 Beta), with c++ -O1 -fexpensive-optimizations
-ftree-vrp -Werror=array-bounds, the attachment fails to compile, with the
following message:

<source>: In function 'void Initialize(int)':
<source>:9:53: error: array subscript -1 is below array bounds of 'int [8]'
[-Werror=array-bounds]
    9 |   int phys_core = VirtualToPhysicalCoreMap[virt_core];
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
<source>:2:5: note: while referencing 'VirtualToPhysicalCoreMap'
    2 | int VirtualToPhysicalCoreMap[8];
      |     ^~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: some warnings being treated as errors
Compiler returned: 1

virt_core does not have a compile time-constant evaluation, so this warning is
bogus. The bogus warning does not appear in older versions of GCC.

Removing either -fexpensive-optimizations or -ftree-vrp allows compilation to
succeed.

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 13:21 [Bug tree-optimization/105420] New: Bogus -Warray-bounds with non-compile time-constant variable byteslice at airmail dot cc
2022-04-29  6:26 ` [Bug tree-optimization/105420] " rguenth at gcc dot gnu.org
2022-04-29 11:42 ` byteslice at airmail dot cc

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