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

            Bug ID: 119274
           Summary: [15 Regression] False positive array-bounds warning
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: larsbj at gullik dot org
  Target Milestone: ---

Created attachment 60741
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60741&action=edit
Unreduced test case

This test case compiles without warnings with GCC 14, but gives warnings with
GCC 15.

Compiled with:
g++ -Wfatal-errors -Werror=array-bounds -O2 -std=gnu++23 -c test.cpp

g++ (GCC) 15.0.1 20250313 (experimental)

g++ -Wfatal-errors -Werror=array-bounds -O2 -std=gnu++23 -c test.cpp


In file included from
/opt/gcc/gcc-15/include/c++/15.0.1/bits/hashtable_policy.h:36,
                 from /opt/gcc/gcc-15/include/c++/15.0.1/bits/hashtable.h:37,
                 from
/opt/gcc/gcc-15/include/c++/15.0.1/bits/unordered_map.h:33,
                 from /opt/gcc/gcc-15/include/c++/15.0.1/unordered_map:43,
                 from /opt/gcc/gcc-15/include/c++/15.0.1/functional:65,
                 from test.cpp:1:
In function ‘constexpr void std::__assign_one(_OutIter&, _InIter&) [with bool
_IsMove = true; _OutIter = int*; _InIter = int*]’,
    inlined from ‘constexpr _OutIter std::__copy_move_a2(_InIter, _Sent,
_OutIter) [with bool _IsMove = true; _InIter = int*; _Sent = int*; _OutIter =
int*]’ at /opt/gcc/gcc-15/include/c++/15.0.1/bits/stl_algobase.h:433:34,
    inlined from ‘constexpr _OI std::__copy_move_a1(_II, _II, _OI) [with bool
_IsMove = true; _II = int*; _OI = int*]’ at
/opt/gcc/gcc-15/include/c++/15.0.1/bits/stl_algobase.h:492:42,
    inlined from ‘constexpr _OI std::__copy_move_a(_II, _II, _OI) [with bool
_IsMove = true; _II = __gnu_cxx::__normal_iterator<int*, vector<int> >; _OI =
__gnu_cxx::__normal_iterator<int*, vector<int> >]’ at
/opt/gcc/gcc-15/include/c++/15.0.1/bits/stl_algobase.h:500:31,
    inlined from ‘constexpr _OI std::move(_II, _II, _OI) [with _II =
__gnu_cxx::__normal_iterator<int*, vector<int> >; _OI =
__gnu_cxx::__normal_iterator<int*, vector<int> >]’ at
/opt/gcc/gcc-15/include/c++/15.0.1/bits/stl_algobase.h:674:38,
    inlined from ‘constexpr std::vector<_Tp, _Alloc>::iterator std::vector<_Tp,
_Alloc>::_M_erase(iterator, iterator) [with _Tp = int; _Alloc =
std::allocator<int>]’ at
/opt/gcc/gcc-15/include/c++/15.0.1/bits/vector.tcc:201:6,
    inlined from ‘constexpr std::vector<_Tp, _Alloc>::iterator std::vector<_Tp,
_Alloc>::erase(const_iterator, const_iterator) [with _Tp = int; _Alloc =
std::allocator<int>]’ at
/opt/gcc/gcc-15/include/c++/15.0.1/bits/stl_vector.h:1735:17,
    inlined from ‘void drop_inplace(std::vector<int>&, size_t)’ at
test.cpp:9:16,
    inlined from ‘test()::<lambda()>’ at test.cpp:17:25,
    inlined from ‘constexpr _Res std::__invoke_impl(__invoke_other, _Fn&&,
_Args&& ...) [with _Res = void; _Fn = test()::<lambda()>&; _Args = {}]’ at
/opt/gcc/gcc-15/include/c++/15.0.1/bits/invoke.h:63:36,
    inlined from ‘constexpr std::enable_if_t<((bool)is_invocable_r_v<_Res,
_Callable, _Args ...>), _Res> std::__invoke_r(_Callable&&, _Args&& ...) [with
_Res = void; _Callable = test()::<lambda()>&; _Args = {}]’ at
/opt/gcc/gcc-15/include/c++/15.0.1/bits/invoke.h:113:28,
    inlined from ‘static _Res std::_Function_handler<_Res(_ArgTypes ...),
_Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Res = void;
_Functor = test()::<lambda()>; _ArgTypes = {}]’ at
/opt/gcc/gcc-15/include/c++/15.0.1/bits/std_function.h:292:30:
/opt/gcc/gcc-15/include/c++/15.0.1/bits/stl_algobase.h:404:16: error: array
subscript 10 is outside array bounds of ‘int [6]’ [-Werror=array-bounds=]
  404 |         *__out = std::move(*__in);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~

Reply via email to