From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6E35D3858D38; Sat, 3 Jun 2023 03:53:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E35D3858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685764435; bh=YO0kX4Id7mP5y6Ze3D1NMYCSdD36mMjGMPDdIMKMYc0=; h=From:To:Subject:Date:From; b=e12HEIDOV2TVBjXdBcQnbsXeq0ww7i5+AWrakkQsilIjIFEJyjmTcBqeNmbwIIOjf JFBNoAN8PcFZYW8vSqF7xJxCmEsRklNI7aKagwltzeSfus1akYt5BHUYgFCxOHT4UQ WqS4PWKYCdLJ50g2DWukXrn07fziV5yQBAcnyiPk= From: "arthur.j.odwyer at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/110102] New: [13 regression] initializer_list ctors of containers skip Allocator_traits::construct, copies move-only type Date: Sat, 03 Jun 2023 03:53:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: accepts-invalid 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110102 Bug ID: 110102 Summary: [13 regression] initializer_list ctors of containers skip Allocator_traits::construct, copies move-only type Product: gcc Version: 13.1.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: arthur.j.odwyer at gmail dot com Target Milestone: --- // https://godbolt.org/z/4Gq3TWE6M #include struct A { A(int) {} A(const A&) =3D delete; A(A&&) {} }; int main() { std::list v =3D {1,2,3}; } This should be ill-formed, but GCC 13.1 accepts it! GCC 12.3 and earlier correctly reject it. This is supposed to be constructing a std::initializer_list and calling `list::list(initializer_list)`, which should then complain because `A(co= nst A&)` is deleted. My guess as to what's happening here: - We're definitely calling list(initializer_list) - It's calling _M_range_initialize(il.begin(), il.end()) - That's calling __uninitialized_copy_a - That's probably somehow deciding that because `A` is trivially copyable, = we can just memcpy it. I.e. bug #89164 redux. Even if it were copyable, we still wouldn't be allowed to bypass `allocator_traits::construct`. The above snippet uses std::allocator, but I originally found a more complicated case with pmr::polymorphic_allocator: // https://godbolt.org/z/ToT6dW5dM #include #include #include struct Widget { using allocator_type =3D std::pmr::polymorphic_allocator; Widget(int i) : i_(i) {} explicit Widget(int i, allocator_type) : i_(i) {} explicit Widget(const Widget& rhs, allocator_type) : i_(rhs.i_ + 100) {} int i_; }; static_assert(std::is_trivially_copyable_v); int main() { std::pmr::vector v =3D {1,2,3}; printf("%d %d %d\n", v[0].i_, v[1].i_, v[2].i_); } My understanding is that this should print "101 102 103", as GCC 12 does. B= ut GCC 13.1 prints "1 2 3" instead.=