From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D969B3858025; Thu, 30 Sep 2021 02:45:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D969B3858025 From: "de34 at live dot cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102535] New: __is_trivially_constructible rejects some trivial cases in aggregate initializations Date: Thu, 30 Sep 2021 02:45:01 +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: 10.1.0 X-Bugzilla-Keywords: 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 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: Thu, 30 Sep 2021 02:45:02 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102535 Bug ID: 102535 Summary: __is_trivially_constructible rejects some trivial cases in aggregate initializations Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: de34 at live dot cn Target Milestone: --- It seems that gcc's __is_trivially_constructible (the underlying mechanism = of std::is_trivially_constructible in libstdc++) gives inconsistent answers to whether aggregate initializations performed by direct-non-list-initializati= ons (available since C++20) affect triviality of operations. #include #include struct A { int x; }; struct B { float y; }; struct C { A a; B b; }; int main() { #if __cpp_aggregate_paren_init >=3D 201902L=20 std::cout << std::is_constructible_v << '\n' // 1 << std::is_constructible_v << '\n' // 1 << !std::is_constructible_v << '\n' // 1 << std::is_trivially_constructible_v << '\n' // 1 << std::is_trivially_constructible_v << '\n'; // 0, seems buggy #endif } According to the definitions, initialization of a C variable from A or A an= d B (both treated as xvalues according to [meta.unary.prop]/8) only calls trivi= al move constructors. It seems unreasonable that std::is_trivially_constructible_v is true but std::is_trivially_constructible_v is false, they should be both tr= ue in C++20. This bug has been existing since gcc 10.1.0, and is not fixed in 12.0.0 20210721: https://wandbox.org/permlink/L0ZLipQZLsCOqYcT https://wandbox.org/permlink/lBwowJpeFshRC03z=