From 7934db5eb113dd6c4febb13b7666a21503dfd2ff Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 3 Feb 2023 10:56:49 -0800 Subject: [PATCH] Ignore GCC10+ memcpy overflow warning --- include/boost/charconv/detail/memcpy.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/boost/charconv/detail/memcpy.hpp b/include/boost/charconv/detail/memcpy.hpp index aebf1b7..15ec0aa 100644 --- a/include/boost/charconv/detail/memcpy.hpp +++ b/include/boost/charconv/detail/memcpy.hpp @@ -9,6 +9,19 @@ #include #include +// GCC 10 added checks for length of memcpy which yields the following warning (converted to error with -Werror) +// /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:33: error: +// ‘void* __builtin___memcpy_chk(void*, const void*, long unsigned int, long unsigned int)’ specified size between +// 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=] +// +// memcpy is defined as taking a size_t for the count and the largest count this will recieve is the number of digits +// in a 128-bit int (39) so we can safely ignore +#if __GNUC__ >= 10 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wstringop-overflow" +# define BOOST_CHARCONV_STRINGOP_OVERFLOW_DISABLED +#endif + namespace boost { namespace charconv { namespace detail { #if !defined(BOOST_CHARCONV_NO_CONSTEXPR_DETECTION) && defined(BOOST_CXX14_CONSTEXPR) @@ -45,4 +58,8 @@ inline void* memcpy(void* dest, const void* src, std::size_t count) }}} // Namespace boost::charconv::detail +#ifdef BOOST_CHARCONV_STRINGOP_OVERFLOW_DISABLED +# pragma GCC diagnostic pop +#endif + #endif // BOOST_CHARCONV_DETAIL_MEMCPY_HPP