atomic_queue: build failure with gcc-13
atomic_queue fails to build from source with Gcc 13 on today’s Debian sid. The relevant part of the error message starts like:
In file included from /usr/include/c++/13/bits/atomic_base.h:39,
from /usr/include/c++/13/atomic:41,
from include/atomic_queue/defs.h:7,
from include/atomic_queue/atomic_queue.h:7,
from /<<PKGBUILDDIR>>/src/benchmarks.cc:5:
In function ‘std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = thread::id]’,
inlined from ‘void std::thread::swap(std::thread&)’ at /usr/include/c++/13/bits/std_thread.h:193:16,
inlined from ‘std::thread& std::thread::operator=(std::thread&&)’ at /usr/include/c++/13/bits/std_thread.h:187:11,
inlined from ‘{anonymous}::cycles_t {anonymous}::benchmark_throughput(atomic_queue::HugePages&, const std::vector<unsigned int>&, unsigned int, unsigned int, bool, sum_t*) [with Queue = atomic_queue::RetryDecorator<CapacityToConstructor<atomic_queue::AtomicQueueB<unsigned int, atomic_queue::HugePageAllocator<unsigned int>, 0, false, false, true>, 65536> >]’ at /<<PKGBUILDDIR>>/src/benchmarks.cc:252:43,
inlined from ‘void {anonymous}::run_throughput_benchmark(const char*, atomic_queue::HugePages&, const std::vector<unsigned int>&, unsigned int, unsigned int, unsigned int) [with Queue = atomic_queue::RetryDecorator<CapacityToConstructor<atomic_queue::AtomicQueueB<unsigned int, atomic_queue::HugePageAllocator<unsigned int>, 0, false, false, true>, 65536> >]’ at /<<PKGBUILDDIR>>/src/benchmarks.cc:292:60:
/usr/include/c++/13/bits/move.h:198:7: error: array subscript 2 is outside array bounds of ‘long long int [1]’ [-Werror=array-bounds=]
198 | __a = _GLIBCXX_MOVE(__b);
| ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/c++allocator.h:33,
from /usr/include/c++/13/bits/allocator.h:46,
from /usr/include/c++/13/memory:65,
from include/atomic_queue/atomic_queue.h:13:
In member function ‘_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = long long int]’,
inlined from ‘static _Tp* std::allocator_traits<std::allocator<_Tp1> >::allocate(allocator_type&, size_type) [with _Tp = long long int]’ at /usr/include/c++/13/bits/alloc_traits.h:482:28,
inlined from ‘std::_Vector_base<_Tp, _Alloc>::pointer std::_Vector_base<_Tp, _Alloc>::_M_allocate(std::size_t) [with _Tp = long long int; _Alloc = std::allocator<long long int>]’ at /usr/include/c++/13/bits/stl_vector.h:378:33,
inlined from ‘std::_Vector_base<_Tp, _Alloc>::pointer std::_Vector_base<_Tp, _Alloc>::_M_allocate(std::size_t) [with _Tp = std::thread; _Alloc = std::allocator<std::thread>]’ at /usr/include/c++/13/bits/stl_vector.h:375:7,
inlined from ‘void std::_Vector_base<_Tp, _Alloc>::_M_create_storage(std::size_t) [with _Tp = std::thread; _Alloc = std::allocator<std::thread>]’ at /usr/include/c++/13/bits/stl_vector.h:395:44,
inlined from ‘std::_Vector_base<_Tp, _Alloc>::_Vector_base(std::size_t, const allocator_type&) [with _Tp = std::thread; _Alloc = std::allocator<std::thread>]’ at /usr/include/c++/13/bits/stl_vector.h:332:26,
inlined from ‘std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::thread; _Alloc = std::allocator<std::thread>]’ at /usr/include/c++/13/bits/stl_vector.h:554:47,
inlined from ‘{anonymous}::cycles_t {anonymous}::benchmark_throughput(atomic_queue::HugePages&, const std::vector<unsigned int>&, unsigned int, unsigned int, bool, sum_t*) [with Queue = atomic_queue::RetryDecorator<CapacityToConstructor<atomic_queue::AtomicQueueB<unsigned int, atomic_queue::HugePageAllocator<unsigned int>, 0, false, false, true>, 65536> >]’ at /<<PKGBUILDDIR>>/src/benchmarks.cc:245:30,
inlined from ‘void {anonymous}::run_throughput_benchmark(const char*, atomic_queue::HugePages&, const std::vector<unsigned int>&, unsigned int, unsigned int, unsigned int) [with Queue = atomic_queue::RetryDecorator<CapacityToConstructor<atomic_queue::AtomicQueueB<unsigned int, atomic_queue::HugePageAllocator<unsigned int>, 0, false, false, true>, 65536> >]’ at /<<PKGBUILDDIR>>/src/benchmarks.cc:292:60:
/usr/include/c++/13/bits/new_allocator.h:147:55: note: at offset 16 into object of size 8 allocated by ‘operator new’
147 | return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
| ^
This issue has initially been reported in Debian bug#1037715. I have been unable to identify what exactly in the porting guide to gcc-13 was relevant to the error at play.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 22 (11 by maintainers)
Commits related to this issue
- Compile with -Wno-error=array-bounds to workarond gcc-13 false positive warning. Resolves #55. — committed to kingtaurus/atomic_queue by deleted user a year ago
Hi jwakely, thanks for jumping in, your comments on the bug title and forwarding the issue to Gcc developers! 😃
Issue retitle is on its way, and I intend to rebuild atomic_queue with -Wno-error=array-bounds for the time being, until resolution on gcc end.
N.B. this is a warning not an error. You’ve chosen to turn it into an error with
-Werror
, but most warnings are imperfect and have false positives.The
-Warray-bounds
warning (like the similar-Wstringop-overflow
and-Wstringop-overread
) is particularly prone to false positives when the compiler is unable to tell that a particular branch is unreachable and so warns about impossible conditions.If you get false positives with particular warnings, don’t use
-Werror
(or use-Wno-error=array-bounds
), or suppress it locally, e.g.I don’t think this warning was introduced by the simpler implicit move changes, I can reproduce it with anything later than GCC 12.1, the warning started with https://gcc.gnu.org/r12-1992
No worries, I’m thankful for the time you already spent on the issue. 😃
I have enough data to move the Debian issue forwards (either by getting the system compiler fixed, dropping optimization level a little for the affected code, or at worse dusting off the build error under the carpet with the patch).
I’ll nudge Gcc maintainers to see whether a bump to 13.1.1 would be feasible, even if this is just to the experimental branch. Maybe we’ll see whether this comes from the older compiler version.
Ahah, silly me, no there was just -O0 to avoid optimizing out the function. Yes, the issue is reproducible with your compiler flags:
Thank you very much!
Thanks for checking, this sounds like that could be caused by an issue in gcc 13.1.0 in Debian. Tag v1.4 still fails in the same way as the git head to me. I’ll pursue investigations in that direction.