The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category
The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category.
The use of implicit conversions between types can lead to unintended results, including possible loss of value, sign, or precision.
For more information on essential types, see MISRA C:2012 Rule
10.1.
The checker raises a violation if an expression is assigned to a variable with a narrower essential type or a different essential type category.
The checker does not raise a violation of this rule:
If the expression is simply the constant zero.
If a signed constant is assigned to an unsigned variable but the signed constant has the same representation as its unsigned equivalent. For instance, the checker does not flag statements such as:
unsigned int u = 1;
The expression is assigned to an object with a different essential type category.
The expression is assigned to an object with a narrower essential type.
If you expect a rule violation but do not see it, refer to the documentation of Polyspace® Code Prover™ or Polyspace Code Prover Server™.
| Group: The Essential Type Model |
| Category: Required |
| AGC Category: Advisory |