public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/110564] New: Incorrect results from floating point computations on x86 when optimized
@ 2023-07-05 19:17 drh at sqlite dot org
  2023-07-05 19:22 ` [Bug ada/110564] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: drh at sqlite dot org @ 2023-07-05 19:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110564

            Bug ID: 110564
           Summary: Incorrect results from floating point computations on
                    x86 when optimized
           Product: gcc
           Version: 9.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: drh at sqlite dot org
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 55484
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55484&action=edit
bug.c - compile and run to demonstrate the problem

Simplified test case attached.  Incorrect floating point result on Linux x86
when compiling and running as follows:

    gcc bug.c -m32 -O1 && ./a.out

The problem goes away under any one or more of the following conditions:

  *  Omit the -m32 flag (to generate x86_64 code)
  *  Omit the -O flag or use -O0
  *  Add the -ffloat-store option
  *  Uncomment both of the "printf()" statements in the test case

Please advise if I am doing something wrong (undefined or unspecified behavior)
so that I might fix it.

SQLite bug report at https://sqlite.org/forum/forumpost/ee7278611394034c.  A
work-around has been checked into SQLite at
https://sqlite.org/src/info/5d9e9364808793d6.  Please advise if there is a
better work-around.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug ada/110564] Incorrect results from floating point computations on x86 when optimized
  2023-07-05 19:17 [Bug ada/110564] New: Incorrect results from floating point computations on x86 when optimized drh at sqlite dot org
@ 2023-07-05 19:22 ` pinskia at gcc dot gnu.org
  2023-07-05 19:25 ` [Bug target/110564] " pinskia at gcc dot gnu.org
  2023-07-05 23:05 ` ebotcazou at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-05 19:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110564

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Either use -fexcess-precision=standard or -std=c99 .

Basically this is a dup of bug 323.

*** This bug has been marked as a duplicate of bug 323 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/110564] Incorrect results from floating point computations on x86 when optimized
  2023-07-05 19:17 [Bug ada/110564] New: Incorrect results from floating point computations on x86 when optimized drh at sqlite dot org
  2023-07-05 19:22 ` [Bug ada/110564] " pinskia at gcc dot gnu.org
@ 2023-07-05 19:25 ` pinskia at gcc dot gnu.org
  2023-07-05 23:05 ` ebotcazou at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-05 19:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110564

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>undefined or unspecified behavior

Neither. Basically GCC uses excess-precision for the fpu as supplied by x87
(80bit IEEE FPU).  Anyways read bug 323 and all of the specifications around FP
math and more.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/110564] Incorrect results from floating point computations on x86 when optimized
  2023-07-05 19:17 [Bug ada/110564] New: Incorrect results from floating point computations on x86 when optimized drh at sqlite dot org
  2023-07-05 19:22 ` [Bug ada/110564] " pinskia at gcc dot gnu.org
  2023-07-05 19:25 ` [Bug target/110564] " pinskia at gcc dot gnu.org
@ 2023-07-05 23:05 ` ebotcazou at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2023-07-05 23:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110564

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org

--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Yes, everybody should use -mfpmath=sse these days on x86.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-05 23:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-05 19:17 [Bug ada/110564] New: Incorrect results from floating point computations on x86 when optimized drh at sqlite dot org
2023-07-05 19:22 ` [Bug ada/110564] " pinskia at gcc dot gnu.org
2023-07-05 19:25 ` [Bug target/110564] " pinskia at gcc dot gnu.org
2023-07-05 23:05 ` ebotcazou at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).