Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
772 Discussions

Intel C++ compiler warning when using isnan/isinf

Dan78
Novice
896 Views

Hi all,

I have observed recently (I am using latest update of Intel compilers i.e., version Intel(R) oneAPI DPC++/C++ Compiler 2024.1.0 (2024.1.0.20240308)) that icpx returns warning when compiling a simple code that used "isnan" std function and the warning is:

 

warning: explicit comparison with NaN in fast floating point mode [-Wtautological-constant-compare]

 

The code I use for testing is:

#include <iostream>
#include <complex>
#include <cmath>

using namespace std;

int main() {
 int xxx;

 xxx = sqrt(-1);

 auto b = std::isnan(xxx);
 cout << "b is: " << b << endl;

 return 0;
}

Is there any way to modify my code to avoid getting this warning? GNU compilers do not show such warning.

Regards,

Dan

 

0 Kudos
1 Solution
Viet_H_Intel
Moderator
821 Views

DPC++/C++ compiler is LLVM base. So, clang++ should give a warning on the same code as well.

For floating point, fast mode is on by default with icpx 

If you don't want to see the warning message, you can compile with -fp-model strict/precise or with -Wno-tautological-constant-compare flag. 

Here is link to clang++ https://godbolt.org/z/bv746h51r 

 

Thanks,

Viet

View solution in original post

2 Replies
Viet_H_Intel
Moderator
822 Views

DPC++/C++ compiler is LLVM base. So, clang++ should give a warning on the same code as well.

For floating point, fast mode is on by default with icpx 

If you don't want to see the warning message, you can compile with -fp-model strict/precise or with -Wno-tautological-constant-compare flag. 

Here is link to clang++ https://godbolt.org/z/bv746h51r 

 

Thanks,

Viet

Dan78
Novice
807 Views

Thanks a lot. I had included "-fp-model precise" in the Makefile but I had to change it to "-fp-model=precise" and now the warning is gone.

 

0 Kudos
Reply