MISRA C++:2008 Rule 5-0-6
An implicit integral or floating-point conversion shall not reduce the size of the underlying type
Description
Rule Definition
An implicit integral or floating-point conversion shall not reduce the size of the underlying type.
Rationale
A conversion that reduces the size of the underlying type can result in loss of information. Unless you explicitly cast to the narrower type, it is not clear whether the loss of information is intended.
Polyspace Implementation
The checker flags implicit conversions that reduce the size of a type.
If the conversion is to a narrower integer with a different sign, then rule 5-0-4 takes precedence over rule 5-0-6. Only rule 5-0-4 is shown.
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Expressions |
Category: Required |
Version History
Introduced in R2013b