public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109359] New: Compile-time rounding of double literal to float is incorrect with -frounding-math
@ 2023-03-31 12:33 rcopley at gmail dot com
  2023-03-31 13:23 ` [Bug c++/109359] [12/13 Regression] " rguenth at gcc dot gnu.org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: rcopley at gmail dot com @ 2023-03-31 12:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109359
           Summary: Compile-time rounding of double literal to float is
                    incorrect with -frounding-math
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rcopley at gmail dot com
  Target Milestone: ---

The following program should print:
0.001914
0.630538

With "g++ -frounding-math", it prints instead:
-8023756970655744.000000
0.872496

This bug is present in trunk, and since gcc 12.1, and does not appear to be
platform specific.

Compiler explorer link: https://godbolt.org/z/aMhcYcY66



#include <cstdio>
float xs[] = {0.001914, 0.630539};
int main() {
  std::size_t size = sizeof xs / sizeof xs[0];
  for (std::size_t i = 0; i != size; ++i) {
    std::printf("%f\n", xs[i]);
  }
}

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

end of thread, other threads:[~2024-02-05 22:26 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-31 12:33 [Bug c++/109359] New: Compile-time rounding of double literal to float is incorrect with -frounding-math rcopley at gmail dot com
2023-03-31 13:23 ` [Bug c++/109359] [12/13 Regression] " rguenth at gcc dot gnu.org
2023-03-31 13:36 ` jakub at gcc dot gnu.org
2023-03-31 14:23 ` jakub at gcc dot gnu.org
2023-04-14  9:49 ` rguenth at gcc dot gnu.org
2023-04-14 10:03 ` jakub at gcc dot gnu.org
2023-04-14 10:08 ` rguenth at gcc dot gnu.org
2023-04-14 10:12 ` jakub at gcc dot gnu.org
2023-05-08 12:26 ` [Bug c++/109359] [12/13/14 " rguenth at gcc dot gnu.org
2024-02-05 18:24 ` jason at gcc dot gnu.org
2024-02-05 18:34 ` [Bug c++/109359] [12/13 " jason at gcc dot gnu.org
2024-02-05 18:47 ` jakub at gcc dot gnu.org
2024-02-05 18:55 ` jason at gcc dot gnu.org
2024-02-05 21:35 ` cvs-commit at gcc dot gnu.org
2024-02-05 22:25 ` cvs-commit at gcc dot gnu.org
2024-02-05 22:25 ` cvs-commit at gcc dot gnu.org
2024-02-05 22:26 ` jason 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).