From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2290D3858D32; Sun, 19 Nov 2023 00:37:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2290D3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700354231; bh=OXIPDBmPasrRDkDhpBVqF4ElTlDBTGHilx+Kga13dSk=; h=From:To:Subject:Date:From; b=o1aHHjnChoEx6VHFDMZHJiSAUnUcRPa/zWbgDlvRfGPg4oIw/g5/5V3PP23xktzau FwaAXLSxEpu5itLHrZGpQoqbwReJRZwxPzqCWXdpyq1Q8pD76Yb/L3ZOc9z/Fk6jYF 9N4Czu17W7xe7JT7gYnGbxOFiIaMH7nPQRp0v5DE= From: "terra at gnome dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/112614] New: Compile-time float-to-_Decimal64 fails for -NAN Date: Sun, 19 Nov 2023 00:37:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.4.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: terra at gnome dot 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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=3D112614 Bug ID: 112614 Summary: Compile-time float-to-_Decimal64 fails for -NAN Product: gcc Version: 11.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: terra at gnome dot org Target Milestone: --- Created attachment 56636 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D56636&action=3Dedit Preprocessed source code It looks like compile-time conversion of -NAN and -(double)NAN to _Decimal64 fails. Runtime conversion seems ok. -INFINITY is ok. Tentatively blaming the C front end. $ gcc -Wall -O2 d64nansign.c $ ./a.out=20 Sign bit set as expected Sign bit set as expected Sign bit not set as expected Sign bit not set as expected Sign bit set as expected Sign bit set as expected Target: x86_64-linux-gnu #include #include #include #include #include #include static void test (_Decimal64 x) { uint64_t u; assert (sizeof (x) =3D=3D sizeof (u)); memcpy (&u, &x, sizeof(x)); if (u >> 63) { printf ("Sign bit set as expected\n"); } else { printf ("Sign bit not set as expected\n"); } } int main (int argc, char **argv) { // compile-time test (-(_Decimal64)(NAN)); test (-(_Decimal64)(NAN)); test ((_Decimal64)(-NAN)); // Fails test ((_Decimal64)(-(double)NAN)); // Fails // runtime test (atof("-nan")); test (-atof("nan")); }=