...
Automated detection of narrowing conversions on integral types is straightforward. Determining whether such conversions correctly reflect the intent of the programmer is infeasible in the general case. Heuristic warnings could be useful.
Related Guidelines
C Secure Coding Standard |
...
...
"FLP34-C. Ensure that floating point conversions are within range of the new type" |
C++ Secure Coding Standard |
...
...
...
CWE-681 "Incorrect Conversion between Numeric Types" | |
|
...
...
-197 "Numeric Truncation Error" |
Bibliography
...