From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0605E385B531; Sat, 25 Feb 2023 11:40:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0605E385B531 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677325249; bh=xtACw+boQwTuiiOZ3OkI2D8Z8ntu81oNXxIfLhANRKc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ta4CzLacX05nkSPXd13o3/eqJbWiTlpXFaH+D56g4Mgezgz9JVL3Zwa2aez6EwYs8 Fie5JtaAVd7um/gN8zhAVzuUiUALmX/c1GAoQHi2fTx+NVqPOqjtr12qL2iWclPxse P47z+CTHDmi55dPh3vV9JP0wiYFVW4TiWCdUyxVE= From: "dangelog at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/108846] std::copy, std::copy_n and std::copy_backward on potentially overlapping subobjects Date: Sat, 25 Feb 2023 11:40:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ABI X-Bugzilla-Severity: normal X-Bugzilla-Who: dangelog at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108846 --- Comment #15 from Giuseppe D'Angelo --- That's not what I meant; a type can be trivial(ly copyable) and move-only. Here's a modification of Arthur's example: // move-only struct B { B(int i, short j) : i(i), j(j) {} B(B &&) =3D default; B &operator=3D(B &&) =3D default; int i; short j;=20 }; struct D : B { D(int i, short j, short x) : B(i, j), x(x) {} D(D &&) =3D default; D &operator=3D(D &&) =3D default; short x; }; int main() { D ddst(1, 2, 3); D dsrc(4, 5, 6); B *dst =3D &ddst; B *src =3D &dsrc; static_assert(std::is_trivially_copyable_v); std::move(src, src+1, dst); assert(ddst.x =3D=3D 3);=20 } The call to std::move ends up in the same memmove codepath as std::copy_n (= B is trivially copyable), but with the proposed patch it will fail to compile because it's not actually copy assignable.=