public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/94111] New: Wrong optimization: decimal floating-point infinity casted to double -> zero
@ 2020-03-09 21:07 ch3root at openwall dot com
  2020-03-10  9:47 ` [Bug middle-end/94111] Wrong constant folding: " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ch3root at openwall dot com @ 2020-03-09 21:07 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94111
           Summary: Wrong optimization: decimal floating-point infinity
                    casted to double -> zero
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ch3root at openwall dot com
  Target Milestone: ---

Cast to double of a decimal floating-point infinity gives zero:

----------------------------------------------------------------------
#include <math.h>
#include <string.h>
#include <stdio.h>

int main()
{
    _Decimal32 d = (_Decimal32)INFINITY;

    unsigned u;
    memcpy(&u, &d, sizeof u);
    printf("repr: %08x\n", u);

    printf("cast: %g\n", (double)d);
}
----------------------------------------------------------------------
$ gcc -std=c2x -pedantic -Wall -Wextra test.c && ./a.out
repr: 78000000
cast: inf
$ gcc -std=c2x -pedantic -Wall -Wextra -O3 test.c && ./a.out
repr: 78000000
cast: 0
----------------------------------------------------------------------
gcc x86-64 version: gcc (GCC) 10.0.1 20200305 (experimental)
----------------------------------------------------------------------

The representation is right for infinity in _Decimal32.

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

end of thread, other threads:[~2020-09-17 17:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-09 21:07 [Bug middle-end/94111] New: Wrong optimization: decimal floating-point infinity casted to double -> zero ch3root at openwall dot com
2020-03-10  9:47 ` [Bug middle-end/94111] Wrong constant folding: " rguenth at gcc dot gnu.org
2020-03-10  9:58 ` jakub at gcc dot gnu.org
2020-03-10 10:00 ` jakub at gcc dot gnu.org
2020-03-10 11:48 ` jakub at gcc dot gnu.org
2020-03-11  8:37 ` jakub at gcc dot gnu.org
2020-03-17 18:57 ` cvs-commit at gcc dot gnu.org
2020-09-17 14:24 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:16 ` jakub 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).