ispc
ispc copied to clipboard
Warnings for literals not fitting the target type
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
doubletype qualifier, i.e.dsuffix and hence the literal is treated asfloatand 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]