llvm / llvm/llvm-project

-Wfloat-equal does not check for exact representation correctly

Open
#220,746 5 comments 0 reactions 0 assignees View on GitHub
clang:diagnostics
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The following program demonstrates the issue:
```cpp
bool test(double d){
return d==1.100000000000000088817841970012523233890533447265625;
}
```
This generates -Wfloat-equal, but writing the equivalent value as a hexadecimal floating literal `0X1199999999999AP-52` instead of `1.100000000000000088817841970012523233890533447265625` causes no warning to be generated.

Contributor guide

Open the contributing guide

Research direction

Start by compiling the supplied C++ reproducer with -Wfloat-equal and compare the decimal and hexadecimal spellings shown in the issue. Trace the warning decision for these two equivalent literals, then verify that the warning behavior is consistent for both forms.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.