[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1041607: marked as done (False positive -Warray-bounds warning)



Your message dated Tue, 24 Jun 2025 21:16:04 +0200
with message-id <CAKZYK48Lg_DeeBft=8MPesA+TZXPB_r8PmaaO_rnLn+eebhiGQ@mail.gmail.com>
and subject line Re: False positive -Warray-bounds warning
has caused the Debian Bug report #1041607,
regarding False positive -Warray-bounds warning
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
1041607: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1041607
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: libstdc++-13-dev
Version: 13.1.0-8
Severity: normal
Tags: upstream
Control: affects -1 src:libatomic-queue

Dear Maintainer,

While investigating the resolution of #1037715 affecting the
libatomic-queue package with upstream[1], it has appeared that
the bug didn't show up in Fedora with gcc 13.1.1[2].

There is a patch against libatomic-queue[3] which resolves the
issue, but from upstream's perspective, this patch is incorrect
because I understand it would fail analysis by tools such as
valgrind or clang's thread sanitizer.

The compiler error seems to raise that the definition of:
	std::thread& std::thread::operator=(std::thread&&)
didn't migrate to the new rule for implicit move[4], ultimately
causing the build failure.

There is no minimal reproducer for the moment, apart from
running the build of the libatomic-queue package.  The nearest
approximation of a reproducer looks like this, but it is
probably flawed due to the thread count mismatch on purpose.
The symptom is the same (or very similar to the one encountered
in libatomic-queue build; I haven't spotted the differences
yet), but maybe not the root cause:

	$ cat reproducer.cpp 
	#include <thread>
	#include <vector>
	
	void g(int);
	
	void f() {
	    std::vector<std::thread> threads(1);
	    threads[0] = std::thread(g, 42);
	    threads[1] = std::thread(g, 42);
	    threads[0].join();
	    threads[1].join();
	}

	$ g++ -c -o reproducer.o reproducer.cpp -Wall -Werror -O3
	In file included from /usr/include/c++/13/bits/stl_pair.h:61,
	                 from /usr/include/c++/13/tuple:38,
	                 from /usr/include/c++/13/bits/std_thread.h:39,
	                 from /usr/include/c++/13/thread:45,
	                 from reproducer.cpp:1:
	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 ‘void f()’ at reproducer.cpp:9:35:
	/usr/include/c++/13/bits/move.h:198:7: error: array subscript 1 is outside array bounds of ‘std::thread [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/vector:63,
	                 from reproducer.cpp:2:
	In member function ‘_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = std::thread]’,
	    inlined from ‘static _Tp* std::allocator_traits<std::allocator<_CharT> >::allocate(allocator_type&, size_type) [with _Tp = std::thread]’ 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 = std::thread; _Alloc = std::allocator<std::thread>]’ at /usr/include/c++/13/bits/stl_vector.h:378:33,
	    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 ‘void f()’ at reproducer.cpp:7:39:
	/usr/include/c++/13/bits/new_allocator.h:147:55: note: at offset 8 into object of size 8 allocated by ‘operator new’
	  147 |         return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
	      |                                                       ^
	cc1plus: all warnings being treated as errors

I'm having a hard time determining what the issue is exactly as
I don't speak C++ very well, but I thought you might be
interested in being aware of this case.  Maybe it would be of
interest to have a look back at this once gcc >= 13.1.1~ is
available in the archive.

[1]: https://github.com/max0x7ba/atomic_queue/issues/55
[2]: https://github.com/max0x7ba/atomic_queue/issues/55#issuecomment-1640353462
[3]: https://github.com/max0x7ba/atomic_queue/issues/55#issuecomment-1645325960
[4]: https://github.com/max0x7ba/atomic_queue/issues/55#issuecomment-1645296633

Have a nice day,  :)
Étienne.

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.3.0-2-amd64 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libstdc++-13-dev depends on:
ii  gcc-13-base    13.1.0-8
ii  libc6-dev      2.37-6
ii  libgcc-13-dev  13.1.0-8
ii  libstdc++6     13.1.0-8

libstdc++-13-dev recommends no packages.

Versions of packages libstdc++-13-dev suggests:
pn  libstdc++-13-doc  <none>

-- no debconf information

-- 
  .''`.  Étienne Mollier <emollier@debian.org>
 : :' :  gpg: 8f91 b227 c7d6 f2b1 948c  8236 793c f67e 8f0d 11da
 `. `'   sent from /dev/pts/4, please excuse my verbosity
   `-

Attachment: signature.asc
Description: PGP signature


--- End Message ---
--- Begin Message ---
Not reproducible upstream
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110764) and does not
appear in new builds of atomic_queue anymore.

--- End Message ---

Reply to: