From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 131ED385483B; Wed, 18 Aug 2021 20:44:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 131ED385483B From: "joseph at codesourcery dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/101953] bug on the default cast operator from double to unsigned short Date: Wed, 18 Aug 2021 20:44:52 +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: 8.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: joseph at codesourcery dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Aug 2021 20:44:53 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101953 --- Comment #25 from joseph at codesourcery dot com --- The option to use to detect this is -fsanitize=3Dfloat-cast-overflow (note:= =20 I haven't tested if it detects this particular case). As per the manual:=20 "Unlike other similar options, @option{-fsanitize=3Dfloat-cast-overflow} is= =20 not enabled by @option{-fsanitize=3Dundefined}.". (Annex F makes the resul= t=20 an unspecified value with "invalid" raised, instead of being undefined=20 behavior, which justifies not including it in -fsanitize=3Dundefined by=20 default. That means that each time such a conversion occurs in the=20 abstract machine, some value representable in the result type must be=20 produced; it can't be a "wobbly" value where different uses of the result=20 of the conversion, that was only executed once in the abstract machine,=20 act like different values or like values not of the result type. If such=20 a conversion does produce a wobbly value, that's a bug; see bug 93806=20 comments 27 to 29 for examples of such a bug.)=