public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sbouchex at infovista dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107004] [12 Regression] GCC12 warning in OOB access: array subscript is partly outside array bounds
Date: Tue, 04 Jul 2023 07:53:43 +0000	[thread overview]
Message-ID: <bug-107004-4-4lxV6gSXb6@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107004-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from sbouchex <sbouchex at infovista dot com> ---
(In reply to sbouchex from comment #6)
> The same testcase is failing on :
> 
> [...]
> g++ --version
> g++ (GCC) 13.1.1 20230614 (Red Hat 13.1.1-4)
> [...]
> 
> [...]
> [root@dev-sbo-eva-ol8 CorrCommon]# g++ -std=c++20 -Wall -Wextra -Werror
> -pedantic -Warray-bounds -O3 -o /tmp/toto /tmp/toto.cpp
> In file included from /usr/include/c++/13/bits/stl_iterator.h:85,
>                  from /usr/include/c++/13/bits/stl_algobase.h:67,
>                  from /usr/include/c++/13/vector:62,
>                  from /tmp/toto.cpp:1:
> In function 'constexpr void std::_Construct(_Tp*, _Args&& ...) [with _Tp =
> int*; _Args = {}]',
>     inlined from 'static constexpr _ForwardIterator
> std::__uninitialized_default_n_1<true>::__uninit_default_n(_ForwardIterator,
> _Size) [with _ForwardIterator = int**; _Size = long unsigned int]' at
> /usr/include/c++/13/bits/stl_uninitialized.h:666:23,
>     inlined from 'static constexpr _ForwardIterator
> std::__uninitialized_default_n_1<true>::__uninit_default_n(_ForwardIterator,
> _Size) [with _ForwardIterator = int**; _Size = long unsigned int]' at
> /usr/include/c++/13/bits/stl_uninitialized.h:660:9,
>     inlined from 'constexpr _ForwardIterator
> std::__uninitialized_default_n(_ForwardIterator, _Size) [with
> _ForwardIterator = int**; _Size = long unsigned int]' at
> /usr/include/c++/13/bits/stl_uninitialized.h:706:20,
>     inlined from 'constexpr _ForwardIterator
> std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&)
> [with _ForwardIterator = int**; _Size = long unsigned int; _Tp = int*]' at
> /usr/include/c++/13/bits/stl_uninitialized.h:773:44,
>     inlined from 'constexpr void std::vector<_Tp,
> _Alloc>::_M_default_append(size_type) [with _Tp = int*; _Alloc =
> std::allocator<int*>]' at /usr/include/c++/13/bits/vector.tcc:668:41,
>     inlined from 'constexpr void std::vector<_Tp, _Alloc>::resize(size_type)
> [with _Tp = int*; _Alloc = std::allocator<int*>]' at
> /usr/include/c++/13/bits/stl_vector.h:1013:21,
>     inlined from 'void foo(std::vector<int*>&)' at /tmp/toto.cpp:7:13:
> /usr/include/c++/13/bits/stl_construct.h:119:7: error: array subscript
> 'int*[0]' is partly outside array bounds of 'unsigned char [8]'
> [-Werror=array-bounds=]
>   119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
>       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from
> /usr/include/c++/13/x86_64-redhat-linux/bits/c++allocator.h:33,
>                  from /usr/include/c++/13/bits/allocator.h:46,
>                  from /usr/include/c++/13/vector:63:
> In member function '_Tp* std::__new_allocator<_Tp>::allocate(size_type,
> const void*) [with _Tp = int*]',
>     inlined from 'constexpr _Tp* std::allocator< <template-parameter-1-1>
> >::allocate(std::size_t) [with _Tp = int*]' at
> /usr/include/c++/13/bits/allocator.h:198:40,
>     inlined from 'static constexpr _Tp*
> std::allocator_traits<std::allocator<_Up> >::allocate(allocator_type&,
> size_type) [with _Tp = int*]' at
> /usr/include/c++/13/bits/alloc_traits.h:482:28,
>     inlined from 'constexpr std::_Vector_base<_Tp, _Alloc>::pointer
> std::_Vector_base<_Tp, _Alloc>::_M_allocate(std::size_t) [with _Tp = int*;
> _Alloc = std::allocator<int*>]' at
> /usr/include/c++/13/bits/stl_vector.h:378:33,
>     inlined from 'constexpr void std::vector<_Tp,
> _Alloc>::_M_default_append(size_type) [with _Tp = int*; _Alloc =
> std::allocator<int*>]' at /usr/include/c++/13/bits/vector.tcc:663:45,
>     inlined from 'constexpr void std::vector<_Tp, _Alloc>::resize(size_type)
> [with _Tp = int*; _Alloc = std::allocator<int*>]' at
> /usr/include/c++/13/bits/stl_vector.h:1013:21,
>     inlined from 'void foo(std::vector<int*>&)' at /tmp/toto.cpp:7:13:
> /usr/include/c++/13/bits/new_allocator.h:147:55: note: at offset [1, 8] into
> object of size 8 allocated by 'operator new'
>   147 |         return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n *
> sizeof(_Tp)));
>       |                                                       ^
> cc1plus: all warnings being treated as errors
> [...]


But no warning with -O2

      parent reply	other threads:[~2023-07-04  7:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21 17:51 [Bug tree-optimization/107004] New: " 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 message]

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-107004-4-4lxV6gSXb6@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).