https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111499
Bug ID: 111499 Summary: std::vector<uin8_t> less operator< doesn't compile with optimalisation due to __builtin_memcmp Product: gcc Version: og12 (devel/omp/gcc-12) Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mlachowicz at outlook dot com Target Milestone: --- Hi, Would like to report bug in std::vector<uint8_t> less operator. version of GCC: gcc 12.2, gcc 12.3, gcc 13.1, gcc 13.2 GNU C++20 (GCC) version 12.2.0 (x86_64-unknown-linux-gnu) compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.2.0, MPC version 1.3.1, isl version isl-0.20-GMP system type: (not related to system) the options given when GCC was configured/built: (not related) the complete command line that triggers the bug: g++ -Werror -std=c++20 -O1 f.cpp the compiler output (error messages, warnings, etc.): In file included from /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/vector:60, from <source>:1: In function 'constexpr decltype (__comp((* __first1), (* __first2))) std::lexicographical_compare_three_way(_InputIter1, _InputIter1, _InputIter2, _InputIter2, _Comp) [with _InputIter1 = __gnu_cxx::__normal_iterator<const unsigned char*, vector<unsigned char> >; _InputIter2 = __gnu_cxx::__normal_iterator<const unsigned char*, vector<unsigned char> >; _Comp = __detail::_Synth3way]', inlined from 'constexpr std::__detail::__synth3way_t<_T1> std::operator<=>(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&) [with _Tp = unsigned char; _Alloc = allocator<unsigned char>]' at /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/stl_vector.h:2056:52, inlined from 'bool f(const std::vector<unsigned char>&)' at <source>:6:12: /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/stl_algobase.h:1843:41: error: 'int __builtin_memcmp(const void*, const void*, long unsigned int)' specified bound [9223372036854775808, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Werror=stringop-overread] 1843 | = __builtin_memcmp(&*__first1, &*__first2, __len) <=> 0; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors Compiler returned: 1 Complete set of source files (see below): https://godbolt.org/z/rzznsffne #include <vector> bool f(const std::vector<unsigned char> &v) { std::vector<unsigned char> w; return v < w; } int main () {} Other: Bug exists only for unsigned char. Doesn't exist for signed char. Bug exists only with -O1 option. Doesn't exist with -O0. Let me know if you need more detailed information. Kind regards, MichaĆ