From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5F34E3858D32; Sun, 4 Jun 2023 13:40:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F34E3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685886016; bh=ZruI4W1hVu6aF6rhjfP+2M8pm+bwD1S4iGBVuCtLQXs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=d8bh+r69/uY7hfOLTG+Dg3W/yeatYjOC+HaXbPz3mFJIJGWrsRSpZuAN1eYfF9csX y21WwKALKCEcluWAiTqdM1kJjQQCUsDBZb5ckN4DvwOidze1ZLrbb7agUgOjljBOsd tdWN1tUTZLD2yNpLqbHCz+GpItabW8Lbq1fXOhvk= From: "arthur.j.odwyer at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110102] [13/14 regression] initializer_list ctors of containers skip Allocator_traits::construct, copies move-only type Date: Sun, 04 Jun 2023 13:40:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: accepts-invalid, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: arthur.j.odwyer 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=3D110102 --- Comment #4 from Arthur O'Dwyer --- I came across the `Widget` bug in the course of writing (and it's now menti= oned in) this blog post on value semantics and PMR: https://quuxplusone.github.io/blog/2023/06/03/p1144-pmr-koans/#the-evil-all= ocator-aware-type FWIW I'm highly sympathetic to the idea that `Widget` is "not a sensible program" and I would love to see CWG or LWG make it UB. ;) It would make wh= at I'm trying to do with value semantics in P1144 so much easier if some more = of these "unreasonable programs" were less well-defined. But that seems like a *gigantic* task. My first, reduced, example, where `std::list v =3D {1,2,3}` is accepted = for move-only type `A`, is 100% a bug and should be fixed. But that is easy to = fix. Jason, *I* don't know by what heuristic the optimizer decides to do this optimization or not... but are *you* at all worried that it might be a pessimization for some types? For example, suppose we had struct NthPrime { constexpr NthPrime(int); ... }; std::vector primes =3D {1,2,3,4,5,6}; Here we *want* to make an initializer_list backed by a static arr= ay of NthPrime at compile time. If we make an initializer_list, then we'll have to run the NthPrime(int) constructor at runtime, and that's expensive. I tried out this example on Godbolt and the optimizer made the correct choi= ce in this specific case, so that's good. But I figured I should mention the scenario in case it brings something to your mind.=