From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 293D93858CDA; Fri, 20 Oct 2023 15:29:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 293D93858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697815781; bh=IvGwgDY2eGAGmE38xp/VHrw9/8UQwouGeHggP8ONX+c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=i8JqYZUuQJzBjpLQCoefBiZRn7sKTCY7sGIzidK32LRcIF7Eamlr+96HIFGJZ0J3e LBHOrhy0mM3g1N/zBfA0rpjOuEcdMMfl4McK1USdgtaTxZzFX6De/rqXAptbNGtsZN SOnV/05aHWUhjBrdEmaAWK84zUfv7hhdQT3RPnwI= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111897] Initialization of _Float16 with f.p. constant gives false warning Date: Fri, 20 Oct 2023 15:29:40 +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: 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: cc 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=3D111897 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jonathan Wakely --- The examples in 5.6.1 are not the standard, so are not authoritative. The wording change in 5.7.3 alters [dcl.init.list] which is about list initialization, which is not relevant here. That says that converting 1.0 to _Float16 is not a narrowing conversion, but copy initialization (as used in your example) doesn't reject narrowing conversions anyway. And this isn't a -Wnarrowing warning. Had you written `_Float16 A{1.0};` then it would be list-init, and I think = the warning is wrong for that case. I think the relevant wording for your example is [dcl.init.general] p16 (16= .9): Otherwise, the initial value of the object being initialized is the (possib= ly converted) value of the initializer expression. A standard conversion sequence (7.3) is used to con= vert the initializer expression to a prvalue of the cv-unqualified version of the destination type; no user-defined conversions are considered. If the conversion cannot be done, the initialization is ill-for= med. The relevant kind of standard conversion sequence here is a floating-point conversion, as defined in 7.3.10 [conv.double]. That does not permit conversions to types of lesser rank. So the conversion is ill-formed.=