From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 60C113858002; Wed, 31 Jan 2024 08:40:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60C113858002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706690425; bh=XvIK+6R24JYDdm6US1YxkLatvy4xzvYlWABtGAYQDGw=; h=From:To:Subject:Date:From; b=Ok2LNTsjlA9hrZZujzAI5Fns4SBBuFH/8sTUYrKjefHDCY4ZcNiRsSBW3kAc8wO4n jq48qmcLt3dOFTWUTMH/BeskESPXkTicaULL02mgAtrDClbPO0BDws6S3AcL0EAV2d IPHMD7EncKrpRbPm3ZVZ6low48mR6fExUZQgcXc0= From: "dilyan.palauzov at aegee dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/113679] New: long long minus double with gcc -m32 produces different results than other compilers or gcc -m64 Date: Wed, 31 Jan 2024 08:40:21 +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: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dilyan.palauzov at aegee 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 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=3D113679 Bug ID: 113679 Summary: long long minus double with gcc -m32 produces different results than other compilers or gcc -m64 Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: dilyan.palauzov at aegee dot org Target Milestone: --- diff.c is: #include int main(void) { long long l =3D 9223372036854775806; double d =3D 9223372036854775808.0; printf("%f\n", (double)l - d); return 0; } With gcc (GCC) 13.2.1 20231205 (Red Hat 13.2.1-6), gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0, clang 16.0.4 and clang 17.0.5: $ gcc -m64 -o diff diff.c && ./diff 0.000000 $ gcc -m32 -o diff diff.c && ./diff -2.000000 $ clang -m64 -o diff diff.c && ./diff 0.000000 $ clang -m32 -o diff diff.c && ./diff 0.000000 With cl.exe 19.29.3015319.29.30153 (first is x84 - 32 bit, second is 64 bit) C:\> CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 10.0.17763.0 C:\> cl diff.c >nul 2>nul & .\diff.exe 0.000000 C:\> CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 10.0.17763.0 C:\> cl diff.c >nul 2>nul & .\diff.exe 0.000000 gcc -m32 produces a different result, compared to gcc -m64, clang 17 (32 and 64bit), and MSCV Visual Studio 2019 (32 and 64bit).=