https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101361
Bug ID: 101361 Summary: Bogus -Wstringop-overread warning with -O3 Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: boris at kolpackov dot net Target Milestone: --- Created attachment 51113 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51113&action=edit reproducer g++ -Wall -Wextra -O3 -std=c++2a -o driver.o -c -fdirectives-only driver.ii In file included from /home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.1/string:40, from /home/boris/work/build2/libbutl/tests/prefix-map/driver.cxx:7: In static member function ‘static constexpr int std::char_traits<char>::compare(const char_type*, const char_type*, std::size_t)’, inlined from ‘int butl::compare_prefix<std::__cxx11::basic_string<_CharT> >::compare(const C*, butl::compare_prefix<std::__cxx11::basic_string<_CharT> >::size_type, const C*, butl::compare_prefix<std::__cxx11::basic_string<_CharT> >::size_type) const [with C = char]’ at /home/boris/work/build2/libbutl/libbutl/prefix-map.mxx:93:35, inlined from ‘bool butl::compare_prefix<std::__cxx11::basic_string<_CharT> >::prefix(const K&, const K&) const [with C = char]’ at /home/boris/work/build2/libbutl/libbutl/prefix-map.mxx:70:18, inlined from ‘std::pair<typename M::const_iterator, typename M::const_iterator> butl::prefix_map_common<M>::find_sub(const key_type&) const [with M = std::map<std::__cxx11::basic_string<char>, int, butl::compare_prefix<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >]’ at /home/boris/work/build2/libbutl/libbutl/prefix-map.txx:36:21: /home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.1/bits/char_traits.h:361:32: warning: ‘int __builtin_memcmp_eq(const void*, const void*, long unsigned int)’ specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overread] 361 | return __builtin_memcmp(__s1, __s2, __n); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ In file included from /home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.1/string:55, from /home/boris/work/build2/libbutl/tests/prefix-map/driver.cxx:7: /home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.1/bits/basic_string.h: In member function ‘std::pair<typename M::const_iterator, typename M::const_iterator> butl::prefix_map_common<M>::find_sub(const key_type&) const [with M = std::map<std::__cxx11::basic_string<char>, int, butl::compare_prefix<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >]’: /home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.1/bits/basic_string.h:187:28: note: source object allocated here 187 | { return _M_dataplus._M_p; } | ^~~~ In file included from /home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.1/string:40, from /home/boris/work/build2/libbutl/tests/prefix-map/driver.cxx:7: In static member function ‘static constexpr int std::char_traits<char>::compare(const char_type*, const char_type*, std::size_t)’, inlined from ‘int butl::compare_prefix<std::__cxx11::basic_string<_CharT> >::compare(const C*, butl::compare_prefix<std::__cxx11::basic_string<_CharT> >::size_type, const C*, butl::compare_prefix<std::__cxx11::basic_string<_CharT> >::size_type) const [with C = char]’ at /home/boris/work/build2/libbutl/libbutl/prefix-map.mxx:93:35, inlined from ‘bool butl::compare_prefix<std::__cxx11::basic_string<_CharT> >::prefix(const K&, const K&) const [with C = char]’ at /home/boris/work/build2/libbutl/libbutl/prefix-map.mxx:70:18, inlined from ‘std::pair<typename M::iterator, typename M::iterator> butl::prefix_map_common<M>::find_sub(const key_type&) [with M = std::map<std::__cxx11::basic_string<char>, int, butl::compare_prefix<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >]’ at /home/boris/work/build2/libbutl/libbutl/prefix-map.txx:17:21: /home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.1/bits/char_traits.h:361:32: warning: ‘int __builtin_memcmp_eq(const void*, const void*, long unsigned int)’ specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overread] 361 | return __builtin_memcmp(__s1, __s2, __n); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ In file included from /home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.1/string:55, from /home/boris/work/build2/libbutl/tests/prefix-map/driver.cxx:7: /home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.1/bits/basic_string.h: In member function ‘std::pair<typename M::iterator, typename M::iterator> butl::prefix_map_common<M>::find_sub(const key_type&) [with M = std::map<std::__cxx11::basic_string<char>, int, butl::compare_prefix<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >]’: /home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.1/bits/basic_string.h:187:28: note: source object allocated here 187 | { return _M_dataplus._M_p; } | ^~~~