From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2690B38376C1; Sat, 21 May 2022 09:37:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2690B38376C1 From: "jeanmichael.celerier at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105683] New: [12 Regression] Infinite loop with construction of vector of variant Date: Sat, 21 May 2022 09:37:08 +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.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jeanmichael.celerier 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 bug_severity priority component assigned_to reporter target_milestone attachments.created 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: Sat, 21 May 2022 09:37:09 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105683 Bug ID: 105683 Summary: [12 Regression] Infinite loop with construction of vector of variant Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jeanmichael.celerier at gmail dot com Target Milestone: --- Created attachment 53012 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D53012&action=3Dedit Full repro Hello, Full repro attached (g++ -std=3Dgnu++20 repro.cpp && ./a.out is enough to t= rigger the issue). Same code works fine for every GCC version < 12 in c++17, c++20, as well as with every released clang version in c++17, c++20, with both libc++ and libstdc++. My code more-or-less looks like this (trying to keep only the relevant part= s): // line 58584 struct value_variant_type { union Impl { std::vector m_value8; } m_impl; value_variant_type(const std::vector& v);=20 value_variant_type(std::vector&& v); }; // line 58681 class value { value_variant_type v; value(const std::vector& val) noexcept : v{val} { } explicit value(std::vector&& val) noexcept : v{std::move(val)} { } }; // line 75925 inline value_variant_type::value_variant_type(const std::vector& v) : m_type{Type8} { new (&m_impl.m_value8) std::vector(v); } inline value_variant_type::value_variant_type(std::vector= && v) : m_type{Type8} { new (&m_impl.m_value8) std::vector(std::move(v)); } // line 58916 inline ossia::value init_value(ossia::val_type type) { return std::vector{}; } // line 76232 void create_value_inline(ossia::value& v, ossia::val_type t) { v =3D ossia::init_value(t); } int main() { ossia::value v; create_value_inline(v, ossia::val_type::LIST); } What it looks that is happening is a loop between the construction of the v= alue and of the vector:=20 #1822 0x00005555555587b7 in ossia::value::value (other=3D..., this=3D0x555555abff10) at /home/jcelerier/ossia/score/3rdparty/libossia/src/ossia/network/value/value= .hpp:302 #1823 std::_Construct (__p=3D0x555555abff10) at /usr/include/c++/12.1.0/bits/stl_construct.h:119 #1824 std::__do_uninit_copy (__result=3D, __last=3D, __first=3D0x7fffff80= 2a50) at /usr/include/c++/12.1.0/bits/stl_uninitialized.h:120 #1825 std::__uninitialized_copy::__uninit_copy (__result=3D, __last=3D,=20 __first=3D) at /usr/include/c++/12.1.0/bits/stl_uninitialized.h:137 #1826 std::uninitialized_copy (__result=3D, __last=3D, __first=3D) at /usr/include/c++/12.1.0/bits/stl_uninitialized.h:185 #1827 std::__uninitialized_copy_a (__result=3D0x555555abff10, __last=3D0x7fffff802a78, __first=3D0x7fffff802a50) at /usr/include/c++/12.1.0/bits/stl_uninitialized.h:372 #1828 std::vector >::_M_range_initialize (__last=3D0x7fffff802a78, __first=3D0x7fffff802a50,=20 this=3D0x555555abfee0) at /usr/include/c++/12.1.0/bits/stl_vector.h:1690 #1829 std::vector >::vector (__a=3D..., Python Exception : value has been optimized = out __l=3D, this=3D0x555555abfee0) at /usr/include/c++/12.1.0/bits/stl_vect= or.h:677 #1830 ossia::value_variant_type::value_variant_type (other=3D..., this=3D0x555555abfee0) at /home/jcelerier/ossia/score/3rdparty/libossia/src/ossia/network/value/value= _variant_impl.hpp:17017 #1831 ossia::value::value (other=3D..., this=3D0x555555abfee0) at /home/jcelerier/ossia/score/3rdparty/libossia/src/ossia/network/value/value= .hpp:302=