From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9A1C23856969; Thu, 27 Jul 2023 16:25:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A1C23856969 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690475119; bh=d9C1bP9qyWyeJbi6SxB6pw/NpMrIQBqTNhxvegeq9Rw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=raihbwCq+aVMhEOxtzyVggWKpJYtClWPjqyBr2ROpXAAHMYFAjZs1mUv2PwEVLR0K rh6gff97D0D6zBqQkPS4XUHrIZ04OOncf2KV7KvNfbn9IP4K0WyVa54fSvA1PQuqT0 0sPCf7QhWhuqNTuMWYvnfF+kPkqkwhLbZUI26Uuk= From: "gccbugbjorn at fahller dot se" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110828] union constexpr dtor not constexpr when used in member array Date: Thu, 27 Jul 2023 16:25:19 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: gccbugbjorn at fahller dot se 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110828 --- Comment #2 from Bj=C3=B6rn Fahller --- If I write it in the same way in a function, it compiles. consteval auto f() { return S{}.f(); } constexpr auto b =3D f(); However, if I break it into a constexpr object S s; and return s.f(), it do= es not compile, this time because the construction of 's' fails because it ref= ers to an unititialized variable, regardless of whether the member is an array = or not. union type { constexpr type(){} constexpr ~type() {} int t; }; struct S { constexpr S() {} constexpr bool f() const { return true;} type v{}; }; consteval auto f() { constexpr S s; return s.f(); } constexpr auto b =3D f(); https://godbolt.org/z/68zY6ecxs=