TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - C Coding Standard
Search

Category: EXPRESSIONS

Synopsis:


Description:

Coding Rules

NameCheckedSynopsis
7#1 Checked automatically with code checker Expressions which either mix operators from the set >, >=, <, <=, ==, !=, with operators from the set <<, >>, ^, &, |, &&, || or which use two or more distinct operators from the latter set shall be fully parenthesised and make no use of the C precedence rules.
7#2 Checked automatically with code checker Expressions shall not contain multiple side-effects due either to the same identifier being modified more than once, or due to the same identifier being modified and accessed.
7#3 Checked automatically with code checker Expressions containing multiple function references should be avoided due to the possibility of side-effects occurring in an undefined order.
7.2#1 Checked automatically with code checker Void expressions have no value and must not be used in other expressions.
7.2#2 Checked automatically with code checker Constant expressions must not lead to division by zero.
7.2#3 Checked automatically with code checker The value of an incomplete 'union' must not be used.
7.2#4 Checked automatically with code checker The value of an incomplete 'struct' must not be used.
7.3.4#1 Checked automatically with code checker The increment and decrement operators should not be mixed with prefix forms in the same expression.
7.4.5#1 Checked automatically with code checker Unary minus shall not be applied to an unsigned expression.
7.4.8#1 Checked automatically with code checker sizeof shall not be applied to an expression with side-effects.
7.4.8#2 Checked automatically with code checker Wherever possible, use sizeof entity; rather than sizeof (type);
7.5#1 Checked automatically with code checker Expressions shall not be cast to the same type.
7.5#2 Checked automatically with code checker Explicit casting from and to any other type from void * is forbidden.
7.5#3 Checked automatically with code checker Avoid explicit casting where possible.
7.8#1 The right operand of a shift operator in a constant expression must not be negative or imply too large a shift.
7.8#2 Checked automatically with code checker The left operand of a shift operator must not be signed.
7.8#3 Left shifts in constant expressions shall not be such as to truncate any bits from the result.
7.9#1 Checked automatically with code checker The operands of relational operators should be parenthesised unless both are simple values, identifiers, or function calls.
7.10#1 Checked automatically with code checker Floating point expressions shall not be compared using either the == or != operators.
7.10#2 Checked automatically with code checker The operands of equality operators should be parenthesised unless both are simple values, identifiers, or function calls.
7.14#1 Checked automatically with code checker The right-hand operand of the logical AND operator shall not contain any side-effects because it is conditionally executed.
7.14#2 Checked automatically with code checker The operands of logical AND should be parenthesised unless both are simple values, identifiers, or function calls.
7.15#1 Checked automatically with code checker The right-hand operand of the logical OR operator shall not contain any side-effects because it is conditionally executed.
7.15#2 Checked automatically with code checker The operands of logical OR shall be parenthesised unless both are simple values, identifiers, or function calls.
7.16#1 Checked automatically with code checker The second and third operands of the conditional operator shall not contain side-effects because they are conditionally executed.
7.16#2 Checked automatically with code checker Use parentheses to improve readability of the conditional operator.
7.16#3 Checked automatically with code checker The convenience of the conditional operator should be weighed against the clarity of the code.
7.18#1 Checked automatically with code checker The comma operator must be used only within a for statement or within macros.
7.18#2 Checked automatically with code checker In general, the comma operator should be avoided.
7.19#1 Arithmetic operations on constant expressions must not lead to wrapround