![]() |
![]() |
1881 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Balancing | |||||||
This message is issued when an equality operator is used with operands of different essential type categories. For example:
/*PRQA S 1-9999 ++*/
/*PRQA S 1881, 1803, 1823 --*/
_Bool boa;
char pca;
enum E {ONE, TWO} ena;
enum F {UNO, DUE} enb;
int sia;
unsigned uia;
float fta;
void f1881 (void)
{
if (boa == pca) ; /* 1881 */
if (boa == ena) ; /* 1881 */
if (boa == sia) ; /* 1881 */
if (boa == uia) ; /* 1881 */
if (boa == fta) ; /* 1881 */
if (pca == ena) ; /* 1881 */
if (pca == sia) ; /* 1881 */
if (pca == uia) ; /* 1881 */
if (pca == fta) ; /* 1881 */
if (ena == enb) ; /* 1881 */
if (ena == sia) ; /* 1881 */
if (ena == uia) ; /* 1881 */
if (ena == fta) ; /* 1803 */
if (sia == uia) ; /* 1823 */
if (sia == fta) ; /* 1803 */
if (uia == fta) ; /* 1803 */
}
MISRA-C:2004 Rules applicable to message 1881:
| Rule 10.1 (Required) | The value of an expression of integer type shall not be implicitly converted to a different underlying type if: a) it is not a conversion to a wider integer type of the same signedness, or b) the expression is complex, or c) the expression is not constant and is a function argument, or d) the expression is not constant and is a return expression |
| Rule 10.2 (Required) | The value of an expression of floating type shall not be implicitly converted to a different type if: a) it is not a conversion to a wider floating type, or b) the expression is complex, or c) the expression is a function argument, or d) the expression is a return expression |
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |