google-cloud-cpp icon indicating copy to clipboard operation
google-cloud-cpp copied to clipboard

Fix workaround for google/benchmark with C++20

Open coryan opened this issue 3 years ago • 2 comments

When we compile google/benchmark with C++20 on Fedora:36 we get a strange error (see below) from this line:

https://github.com/google/benchmark/blob/v1.6.2/src/benchmark.cc#L488

We are working around this by compiling just that library with C++17.

#17 13.16                  from /var/tmp/build/include/benchmark/benchmark.h:186,
#17 13.16                  from /var/tmp/build/src/benchmark.cc:15:
#17 13.16 In static member function 'static constexpr std::char_traits<char>::char_type* std::char_traits<char>::copy(char_type*, const char_type*, std::size_t)',
#17 13.16     inlined from 'static constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /usr/include/c++/12/bits/basic_string.h:423:21,
#17 13.16     inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /usr/include/c++/12/bits/basic_string.tcc:532:22,
#17 13.16     inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /usr/include/c++/12/bits/basic_string.h:1647:19,
#17 13.16     inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /usr/include/c++/12/bits/basic_string.h:815:28,
#17 13.16     inlined from 'size_t benchmark::RunSpecifiedBenchmarks(BenchmarkReporter*, BenchmarkReporter*, std::string)' at /var/tmp/build/src/benchmark.cc:488:12:
#17 13.16 /usr/include/c++/12/bits/char_traits.h:431:56: error: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Werror=restrict]
#17 13.16   431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
#17 13.16       |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#17 13.26 cc1plus: all warnings being treated as errors

coryan avatar Jul 18 '22 21:07 coryan

Can you please assign this to me?...

hitesh-kumain avatar Sep 10 '22 18:09 hitesh-kumain

This has been diagnosed as a GCC / libstd++ bug, see:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105651 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329

I figured this out by reading:

https://github.com/google/benchmark/issues/1398

I think the best thing to do in the google-cloud-cpp project is to wait for these fixes to make it to the Fedora version we use for our builds and then remove the workaround.

coryan avatar Sep 10 '22 20:09 coryan

Still blocked, we need to get back in sync with the google/benchmark support matrix.

coryan avatar Feb 15 '23 19:02 coryan