https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109849
--- Comment #34 from Martin Jambor <jamborm at gcc dot gnu.org> --- (In reply to Jan Hubicka from comment #32) > > /tmp/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:437: > > warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' > > writing between 2 and 9223372036854775806 bytes into a region of size 0 > > overflows the destination [-Wstringop-overflow=] > > It warns on: > > template<bool _IsMove> > struct __copy_move<_IsMove, true, random_access_iterator_tag> > { > template<typename _Tp, typename _Up> > _GLIBCXX20_CONSTEXPR > static _Up* > __copy_m(_Tp* __first, _Tp* __last, _Up* __result) > { > const ptrdiff_t _Num = __last - __first; > if (__builtin_expect(_Num > 1, true)) > __builtin_memmove(__result, __first, sizeof(_Tp) * _Num); > else if (_Num == 1) > std::__copy_move<_IsMove, false, random_access_iterator_tag>:: > __assign_one(__result, __first); > return __result + _Num; > } > }; > > It is likely false positive on a code path that never happens in real > code, but we now optimize it better. > We end up with: <bb 16> [local count: 64736968]: __builtin_memcpy (1B, v$_M_impl$D10203$_M_start_448, _354); IIRC the statement variant is created by jump threading (specifically thread2). Moreover, if I understand the comment in compute_objsize_r about the INTEGER_CST case correctly, small integers are considered potential "result of erroneous null pointer addition/subtraction." So not warning on a constant 1 destination does not seem to be desirable.