ispc icon indicating copy to clipboard operation
ispc copied to clipboard

Warnings for literals not fitting the target type

Open dbabokin opened this issue 4 years ago • 0 comments

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]

dbabokin avatar Dec 07 '21 00:12 dbabokin