From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ACA603858C36; Tue, 4 Jul 2023 14:31:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACA603858C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688481084; bh=trdamI31fnkOX6XX2TCEv8L8v8Y1e4J3iMZL6jLrNGU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wZxQ6iLhdYQVcaIhSt6UTLM1BD60Jt9X4k/K2Z9kdjvX0KAst392NxhO7HvnvURyT Rz6tosfzggR29otdWgeA7tbBHtV7LK6cFVxOYvf1jwA8uw14xdWKjpgDhw00BYhjYK WeFT5+gPGdX+QLxcPgHL5VUY97yl0m359fTNOc9c= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/110542] use of allocated storage after deallocation in a constant expression: std::array of std::vector Date: Tue, 04 Jul 2023 14:31:24 +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: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org 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=3D110542 --- Comment #1 from Jonathan Wakely --- There seem to be two separate bugs here, which I don't understand. The clang error is fixed by: --- a/libstdc++-v3/include/bits/stl_uninitialized.h +++ b/libstdc++-v3/include/bits/stl_uninitialized.h @@ -661,6 +661,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { if (__n > 0) { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __uninitialized_default_n_1:: + __uninit_default_n(__first, __n); +#endif typename iterator_traits<_ForwardIterator>::value_type* __val =3D std::__addressof(*__first); std::_Construct(__val); But this doesn't fix the error with GCC.=