From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BBD533855024; Wed, 2 Jun 2021 02:57:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BBD533855024 From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/100863] 23_containers/unordered_{map,set}/allocator/default_init.cc still fail at runtime even after r12-1153 Date: Wed, 02 Jun 2021 02:57:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka at gcc dot gnu.org 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: 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 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: Wed, 02 Jun 2021 02:57:31 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100863 --- Comment #1 from Patrick Palka --- The problem seems to be that default initialization of an unordered_map/set only default initializes the allocator object rather than value initializing it. This means the allocator's state doesn't get implicitly zeroed out, wh= ich causes the assert inside test01() to fail. A potential fix is to make _Hashtable_alloc's default constructor value initialize the allocator objec= t: --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -1856,7 +1856,10 @@ namespace __detail using __buckets_alloc_traits =3D std::allocator_traits<__buckets_alloc_type>; using __buckets_ptr =3D __node_base_ptr*; - _Hashtable_alloc() =3D default; + _Hashtable_alloc() noexcept(noexcept(__ebo_node_alloc())) + : __ebo_node_alloc() + { } + _Hashtable_alloc(const _Hashtable_alloc&) =3D default; _Hashtable_alloc(_Hashtable_alloc&&) =3D default;=