https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108912
Nicholas Guriev <guriev-ns at ya dot ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |guriev-ns at ya dot ru
--- Comment #6 from Nicholas Guriev <guriev-ns at ya dot ru> ---
Created attachment 65703
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65703&action=edit
yet another reproducer
I encountered a similar problem while debugging the -Wstringop-overflow warning
in GSL, Microsoft Guidelines Support Library. It depends on size of the
translation unit, and I do not know how to minimize my reproducer. But you
might have been interested.
The following command:
aarch64-linux-gnu-g++-16 -std=c++20 -O3 -fno-strict-aliasing -Wall -c
dyn_array_tests.cpp.i -o /dev/null
produces output on stderr:
In file included from /usr/aarch64-linux-gnu/include/c++/16/algorithm:63,
from /build/ms-gsl/include/gsl/dyn_array:25,
from /build/ms-gsl/tests/dyn_array_tests.cpp:4:
In function ‘constexpr void std::generate(_FIter, _FIter, _Generator) [with
_FIter = gsl::details::dyn_array_iterator<char>; _Generator =
dyn_array_tests_use_std_algorithms_Test::TestBody()::<lambda()>]’,
inlined from ‘virtual void
dyn_array_tests_use_std_algorithms_Test::TestBody()’ at
/build/ms-gsl/tests/dyn_array_tests.cpp:160:18:
/usr/aarch64-linux-gnu/include/c++/16/bits/stl_algo.h:4375:18: warning: writing
16 bytes into a region of size 10 [-Wstringop-overflow=]
4375 | *__first = __gen();
| ~~~~~~~~~^~~~~~~~~
In file included from
/usr/aarch64-linux-gnu/include/c++/16/aarch64-linux-gnu/bits/c++allocator.h:33,
from
/usr/aarch64-linux-gnu/include/c++/16/bits/allocator.h:46,
from /usr/aarch64-linux-gnu/include/c++/16/memory:67,
from /usr/include/gtest/gtest.h:55,
from /build/ms-gsl/tests/dyn_array_tests.cpp:1:
In member function ‘constexpr _Tp*
std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = char]’,
inlined from ‘constexpr _Tp* std::allocator< <template-parameter-1-1>
>::allocate(std::size_t) [with _Tp = char]’ at
/usr/aarch64-linux-gnu/include/c++/16/bits/allocator.h:206:40,
inlined from ‘static constexpr _Tp*
std::allocator_traits<std::allocator<_Up> >::allocate(allocator_type&,
size_type) [with _Tp = char]’ at
/usr/aarch64-linux-gnu/include/c++/16/bits/alloc_traits.h:638:28,
inlined from ‘constexpr gsl::details::dyn_array_base<T,
Allocator>::dyn_array_base(size_type, const Allocator&) [with T = char;
Allocator = std::allocator<char>]’ at
/build/ms-gsl/include/gsl/dyn_array:146:76,
inlined from ‘constexpr gsl::dyn_array<T, Allocator>::dyn_array(size_type,
const Allocator&) [with T = char; Allocator = std::allocator<char>]’ at
/build/ms-gsl/include/gsl/dyn_array:378:99,
inlined from ‘virtual void
dyn_array_tests_use_std_algorithms_Test::TestBody()’ at
/build/ms-gsl/tests/dyn_array_tests.cpp:159:36:
/usr/aarch64-linux-gnu/include/c++/16/bits/new_allocator.h:162:76: note: at
offset [16, 26] into destination object of size 26 allocated by ‘operator new’
162 | return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n *
sizeof(_Tp)));
|
^
That is surely a false-positive, because this warning does not appear on target
platforms other than aarch64, or when inlining is not limited by the
large-unit-insns or related params, or if the [[gnu::always_inline]] attribute
is set on the dyn_array_iterator private constructor.
$ aarch64-linux-gnu-g++-16 --version
aarch64-linux-gnu-g++-16 (Debian 16.2.0-3) 16.2.0