public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107004] New: GCC12 warning in OOB access: array subscript is partly outside array bounds
@ 2022-09-21 17:51 rogerio.souza at gmail dot com
  2022-09-22  6:51 ` [Bug tree-optimization/107004] [12/13 Regression] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: rogerio.souza at gmail dot com @ 2022-09-21 17:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107004
           Summary: GCC12 warning in OOB access: array subscript is partly
                    outside array bounds
           Product: gcc
           Version: 12.2.0
               URL: https://godbolt.org/z/aoYh66EYb
            Status: UNCONFIRMED
          Keywords: TREE
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rogerio.souza at gmail dot com
  Target Milestone: ---

The code below triggers the warning:

/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/stl_construct.h:119:7:
warning: array subscript 'int*[0]' is partly outside array bounds of 'unsigned
char [8]' [-Warray-bounds]
  119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Source code:

#include <vector>
#include <cassert>

void foo(std::vector<int*>& v)
{
    assert(v.size() >= 1);
    v.resize(1);
}

Build command line:
g++ -std=c++20 -Wall -Wextra -pedantic -O3

Using -O2 prevents the warning, also if we use "-Wno-array-bounds". This issue
is not reproducible on GCC 11.3 or older.

Would this issue be a duplicate from
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105348?

The issue could be reproduced on Compiler Explorer:
https://godbolt.org/z/aoYh66EYb

Regards,
Rogerio

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

end of thread, other threads:[~2023-07-04  7:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 17:51 [Bug tree-optimization/107004] New: GCC12 warning in OOB access: array subscript is partly outside array bounds rogerio.souza at gmail dot com
2022-09-22  6:51 ` [Bug tree-optimization/107004] [12/13 Regression] " rguenth at gcc dot gnu.org
2022-10-18  8:41 ` rguenth at gcc dot gnu.org
2022-11-29 18:19 ` [Bug tree-optimization/107004] [12 " rguenth at gcc dot gnu.org
2022-11-30 12:25 ` marxin at gcc dot gnu.org
2023-05-08 12:25 ` rguenth at gcc dot gnu.org
2023-05-23 17:31 ` rogerio.souza at gmail dot com
2023-07-04  7:52 ` sbouchex at infovista dot com
2023-07-04  7:53 ` sbouchex at infovista dot com

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