Intel® oneAPI Base Toolkit
Support for the core tools and libraries within the base toolkit that are used to build and deploy high-performance data-centric applications.
419 Discussions

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

vinc17
Beginner
1,327 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
1,314 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.

0 Kudos
NoorjahanSk_Intel
Moderator
1,289 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


0 Kudos
Viet_H_Intel
Moderator
1,271 Views

I've reported this issue to our Compiler Developer.

Thanks for the test case.


0 Kudos
Viet_H_Intel
Moderator
925 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,



0 Kudos
Reply