QMCPACK / QMCPACK/qmcpack

Intel LLVM compiler warning: floating-point comparison

Open
#4,006 2 comments 0 reactions 1 assignee Claimed by @mdewing View on GitHub
Dominant language
C++
Stars
403
Forks
154
Avg merge
1d 13h
Merged PRs (30d)
90

Description

**Describe the bug**
Intel LLVM compiler is more aggressive on warnings. I got the following warning in a mixed precision build.

```
/home/yeluo/opt/qmcpack/src/Numerics/SplineSolvers.h:37:23: warning: floating-point comparison is always true; constant cannot be represented exactly in type 'float' [-Wliteral-range]
T bc_start2 = ((yp0 < 9.9000000000000002e+29) ? (x[0] - x[1]) : (0));
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
/home/yeluo/opt/qmcpack/src/Numerics/SplineSolvers.h:38:23: warning: floating-point comparison is always true; constant cannot be represented exactly in type 'float' [-Wliteral-range]
T bc_end1 = ((ypn < 9.9000000000000002e+29) ? (x[n - 1] - x[n - 2]) : (0));
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
/home/yeluo/opt/qmcpack/src/Numerics/SplineSolvers.h:39:23: warning: floating-point comparison is always true; constant cannot be represented exactly in type 'float' [-Wliteral-range]
T bc_end2 = ((ypn < 9.9000000000000002e+29) ? (2 * x[n - 1] - 2 * x[n - 2]) : (1));
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
/home/yeluo/opt/qmcpack/src/Numerics/SplineSolvers.h:41:13: warning: floating-point comparison is always true; constant cannot be represented exactly in type 'float' [-Wliteral-range]
((yp0 < 9.9000000000000002e+29) ? (6 * yp0 + 6 * y[0] / (-x[0] + x[1]) - 6 * y[1] / (-x[0] + x[1])) : (0));
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
/home/yeluo/opt/qmcpack/src/Numerics/SplineSolvers.h:42:21: warning: floating-point comparison is always true; constant cannot be represented exactly in type 'float' [-Wliteral-range]
T rhs_end = ((ypn < 9.9000000000000002e+29)
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
```

**To Reproduce**
```
cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DENABLE_OFFLOAD=ON -DENABLE_SYCL=ON -DQMC_MIXED_PRECISION=ON ~/opt/qmcpack
```
On JLSE

**Expected behavior**
No warning.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.