Intel® oneAPI Base Toolkit
Support for core tools and libraries to build and deploy high-performance data-centric applications
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
285 Discussions

icx 2021.2.0 bug: incorrect NaN comparison using an identifier with external linkage

vinc17
Beginner
459 Views

Consider the following code:

#include <stdio.h>

double c = 0.0 / 0.0;
static double d = 0.0 / 0.0;

int main (void)
{
  double e = 0.0 / 0.0;
  printf ("%d %.17g\n", c != c, c);
  printf ("%d %.17g\n", d != d, d);
  printf ("%d %.17g\n", e != e, e);
  return 0;
}

With Intel(R) oneAPI DPC++ Compiler 2021.2.0 (2021.2.0.20210317), using the "icx" command, I get the following incorrect output:

0 nan
1 nan
1 nan

i.e. with 0 instead of 1 for the identifier with external linkage (variable c). No such issue with the "clang" command (still from oneAPI 2021.2):

1 nan
1 nan
1 nan

 

0 Kudos
4 Replies
vinc17
Beginner
446 Views

There are also 8 MPFR tests failing apparently due to NaN returned by the library functions (this was actually how I detected the issue with NaN). But I'm not sure about the exact reason.

NoorjahanSk_Intel
Moderator
421 Views

Hi,

Thanks for reaching out to us.

We are looking into this issue internally. we will get back to you soon.

Thanks & Regards

Noorjahan


Viet_H_Intel
Moderator
403 Views

I've reported this issue to our Compiler Developer.

Thanks for the test case.


Viet_H_Intel
Moderator
57 Views

Hi,

Default icx fp-model is fast, which enables fast-math, which enables non-standard things like no-honor-nans.

So code like c != c can be optimized away as false (0). Standard code relying on IEEE 754 floating-point needs fp-model precise at a minimum. Please use -fp-model precise.


$ gcc t12.c &&./a.out

1 nan

$ gcc t12.c -ffast-math &&./a.out

0 nan


$ icx t12.c &&./a.out

0 nan

icx t12.c -fp-model precise &&./a.out

1 nan


We are going to close this as not a defect.


Thanks,



Reply