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

            Bug ID: 103883
           Summary: Signaling NaN is not handled correctly on typedef'd
                    floating-point type
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxcoudert at gcc dot gnu.org
  Target Milestone: ---

Take this code:


#include <stdint.h>
#include <stdio.h>

typedef double GFC_REAL_8;

GFC_REAL_8 foo (void) { return __builtin_nans(""); }
double bar (void) { return __builtin_nans(""); }

int main (void) {
  double x;

  x = __builtin_nans ("");
  printf("==> %lX\n", *(uint64_t *) &x);
  x = foo ();
  printf("==> %lX\n", *(uint64_t *) &x);
  x = bar ();
  printf("==> %lX\n", *(uint64_t *) &x);
}


Compiling this with GCC:

==> 7FF4000000000000
==> 7FF8000000000000
==> 7FF4000000000000

That is, the first and third calls returns a signalling nan, but the second one
returns a quiet nan. -fsignaling-nans fixes the issue, but I do not believe it
should be necessary here. There is no floating-point operation being performed.

See also: Joseph discussion of this issue at
https://gcc.gnu.org/pipermail/gcc/2021-December/237977.html

Reply via email to