From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 272033858C2C; Thu, 14 Dec 2023 01:03:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 272033858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1702515802; bh=0TF85q+0g4aGojAIJxVVZjxYnKXtwB0WXsaeSYMXIz8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gi+gmj9rSfiCS4xY1sVd54/1gRS77mR0xiK7UTyPe5ni6/8jTc6uERj7Hz7c1ZsNP +k1MBEEAxr+fCV76dFlA3UfYSA+booPP13OD2JWuATH/byffRtOEPn43kxXUa9S2TK sD6sN/v+2tXQBQm4XSvGwMOi04lVkTMYxI/WVUQk= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/113007] `std::variant` converting constructor and `operator=` compile while the C++ Standard says they must not Date: Thu, 14 Dec 2023 01:03:21 +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.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113007 --- Comment #2 from Jonathan Wakely --- (In reply to Pavel Novikov from comment #0) > e.g. for `std::variant` the overlo= ad > set would be >=20 > void F(std::monostate) {} > void F(bool) {} > void F(int64_t) {} > void F(double) {} No, because it says: "build an imaginary function FUN(Ti) for each alternative type Ti for which= Ti x[] =3D {std=E2=80=8B::=E2=80=8Bforward(t)}; is well-formed for some inv= ented variable x." That array initializer would be ill-formed for all except int64_t. std::monostate just can't be initialized from an int, and for double and bo= ol it's a narrowing conversion (because of the braces). I think libstdc++ is correct.=