MISRA Discussion Forums
Rule 12.6 - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17)
+---- Forum: 6.12 Expressions (https://forum.misra.org.uk/forumdisplay.php?fid=39)
+---- Thread: Rule 12.6 (/showthread.php?tid=785)



Rule 12.6 - azukich - 27-10-2010

Klocwork has been getting a number of complaints on our interpretation of rule 12.6. For example:

If(TRUE==TRUE) ...

So if TRUE is a Boolean. “==” is not of &&, ||, !. We report this as a violation, since the code should look like
If(TRUE) ...

Many people have debated this. Are we misunderstanding this?


Re: Rule 12.6 - misra-c - 03-11-2010

This rule was clarified in technical corrigendum (TC1) and the wording is now:

Quote:The operands of logical operators (&&, || and !) should be effectively Boolean. Expressions that are effectively Boolean should not be used as operands to operators other than (&&, ||, !, =, ==, != and ?:)

According to this wording, your example:
Code:
if (TRUE==TRUE)
is not a violation of Rule 12.6.