MISRA C:2023 Rule 10.6
The value of a composite expression shall not be assigned to an object with wider essential type
Since R2024a
Description
Rule Definition
The value of a composite expression shall not be assigned to an object with wider essential type1 .
Rationale
A composite expression is a nonconstant expression using a composite operator. In the Essential Type Model, composite operators are:
- Multiplicative ( - *,- /,- %)
- Additive (binary - +, binary- -)
- Bitwise ( - &,- |,- ^)
- Shift ( - <<,- >>)
- Conditional ( - ?,- :)
Unary operators such as ~ and unary +
        or - are also considered composite operators.
If you assign the result of a composite expression to a larger type, the implicit conversion can result in loss of value, sign, precision, or layout.
For more information on essential types, see Essential Types in MISRA C Rules 10.x.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Check Information
| Group: The Essential Type Model | 
| Category: Required | 
| AGC Category: Advisory | 
Version History
Introduced in R2024a
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace® Bug Finder™ documentation are from the following MISRA standards:
- MISRA C:2004 
- MISRA C:2012 
- MISRA C:2023 
- MISRA C++:2008 
- MISRA C++:2023 
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.