Warnings for literals not fitting the target type
- Dominant language
- C++
- Stars
- 3k
- Forks
- 352
- PR merge metrics
- No merged PRs in 30d
Description
Several warnings are needed for numeric literals not fitting the target type:
- integer literals exceeding the target type (example: large integer literal is used to initialize floating point value and being silently truncated)
- floating point literals exceeding the target type (example: missing `double` type qualifier, i.e. `d` suffix and hence the literal is treated as `float` and being truncated / misinterpreted)
Here are C++ examples and clang error messages:
```
> float fff= 170141183460469231731687303715884105728;
t.cpp:3:12: error: integer literal is too large to be represented in any integer type
> float ff = 0x1p+1270f;
t.cpp:4:12: warning: magnitude of floating-point constant too large for type 'float'; maximum is 3.40282347E+38 [-Wliteral-range]
```
Contributor guide
Assessment
This issue has not been assessed yet.