From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B67553851C39; Fri, 28 Jan 2022 03:34:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B67553851C39 From: "de34 at live dot cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104264] New: __is_trivially_copyable fails to report non-recursively trivially copyable classes Date: Fri, 28 Jan 2022 03:34:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: accepts-invalid, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: de34 at live dot cn 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2022 03:34:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104264 Bug ID: 104264 Summary: __is_trivially_copyable fails to report non-recursively trivially copyable classes Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: accepts-invalid, rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: de34 at live dot cn Target Milestone: --- The current definition of trivially copyable class ([class.prop] /2) is not recursive. I.e. a trivially copyable class may have a base class= or data member of a non-trivially copyable class type. The following example is accepted by clang, msvc, and icc, but rejected by = gcc (all of which use __is_trivially_copyable). Perhaps gcc considers Supressor= as non-trivially copyable because it has a non-trivially copyable data member. struct Weird { Weird() =3D default; Weird(const Weird&) =3D default; Weird &operator=3D(const Weird&) =3D default; // non-trivial constexpr Weird(Weird&&) noexcept {} constexpr Weird &operator=3D(Weird&&) noexcept { return *this; } }; struct Supressor { Weird w; Supressor() =3D default; Supressor(const Supressor&) =3D default; Supressor &operator=3D(const Supressor&) =3D default; // move functions are supressed // non-trivial move functions are not called }; int main() { static_assert(!__is_trivially_copyable(Weird), ""); static_assert(__is_trivially_copyable(Supressor), ""); } Compiler Explorer link: https://gcc.godbolt.org/z/4o1vPdz86 The issue might be related to CWG 2463 (https://wg21.link/cwg2463). CWG DR = 1734 seems unrelated,=