From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B17953858D35; Tue, 20 Feb 2024 01:47:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B17953858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708393627; bh=WldQxklXUB17PH9xMo9kLQOIjz+sHOrus01BYullbkQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BahzwH7R7MffibbU3QDiTe3bmk6WELs3zRaYwQXxphTTpdSO+Nu/ejgKW4pj/RDV7 GxPTZo4OucHGTElJFs3vnz+Q4K215+NkUae5X8HQitEpslr/3Pn2k/RiF2CZshZt63 2CvZhPVbJnidwd1h2TN2SEoniTeFJBjVfA7irV7o= From: "de34 at live dot cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/113060] std::variant converting constructor/assignment is non-conforming after P2280? Date: Tue, 20 Feb 2024 01:47:06 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: de34 at live dot cn X-Bugzilla-Status: SUSPENDED 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=3D113060 --- Comment #8 from Jiang An --- (In reply to Giuseppe D'Angelo from comment #7) > Hi, >=20 > > Note that this example adds a mediate function template (test_array_ele= ment_initializable) to "reduce" the non-constexpr-ness of std::declval. >=20 > That's very clever, thank you!=20 >=20 > Is it _supposed_ to work, though? I had imagined (possibly erroneusly) th= at > once one places the call to `test_array_element_initializable` using > `declval` as an argument, it would disqualify the whole thing from being > usable in constant expressions. >=20 > (It would help to have another compiler that implements P2280, so to do m= ore > tests...) I think it's supposed to work. Enclosing std::declval calls don't matter because only the constantness in the trailing return type would affect over= load resolution. Ah, we don't even need to call the function template or function pointers - it's sufficient to only detect the well-formedness of the function type. The simplest "fix" I found is changing `void_t{{std::declval<_Tp>()}})>` to `void_t decltype(_Arr<_Ti>{{std::forward<_Tp>(__t)}})>` , which seemingly works (https://godbolt.org/z/8M85zre5P).=