From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D42393858CD1; Fri, 26 Apr 2024 18:43:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D42393858CD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714157017; bh=a9c2rlq8PbcIDU/E0XB+0O+S9Ew1Ol3kDc9R5xjFe6I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mF1vCpo48hEEKgHiPowoOT2/V1KY0BxERji1os1fMHREgwcPV6AYIiLhDqYICdJSk xhoxhI1EQfmgZtKRvvNXD+hWHQTiHdOpJ1lhNgwPEWN7279wu5q+PUAswlMvPIIj3k LXyUUuAmw6Boi9P91+LngWR9F7DsbZoc8L4tu5LE= From: "arthur.j.odwyer at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/114817] Wrong codegen for std::copy of "trivially copyable but not trivially assignable" type Date: Fri, 26 Apr 2024 18:43:37 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: arthur.j.odwyer at gmail dot com X-Bugzilla-Status: UNCONFIRMED 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=3D114817 --- Comment #3 from Arthur O'Dwyer --- https://github.com/boostorg/container/issues/153 , from 2020, is another similar issue. There, boost::container::vector had assumed that if __has_trivial_copy(T) and is_copy_constructible_v, then T could be reloc= ated via memcpy; but in fact __has_trivial_copy(T) is also true for move-only ty= pes. So it was possible to create a type such that (__has_trivial_copy(T) && __is_constructible(T, T&)) and yet not __is_trivially_constructible(T, T&). // https://godbolt.org/z/x5Wda1M6E struct T { template T(U&&); T(T&&); ~T(); }; static_assert(__has_trivial_copy(T) && __is_constructible(T, T&)); // ...and yet... static_assert(not __is_trivially_constructible(T, T&));=