Next: 11 Functions  Up: index  Previous: 9 Exceptions  Contents

10 Expressions

10.1

High Integrity CPP Rule

Use symbolic names instead of literal values in code. Do not use "magic" numbers.

10.2

High Integrity CPP Rule

Access to an array should be demonstrably within the bounds of the array.

10.3

High Integrity CPP Rule

Do not assume the order of evaluation of operands in an expression.

10.4

High Integrity CPP Rule

Use parentheses in expressions to specify the intent of the expression.

10.5

High Integrity CPP Rule

Always discard the result of an assignment operator.

10.6

High Integrity CPP Guideline

When comparing variables and constants for equality always place the constant on the left hand side.

10.7

High Integrity CPP Guideline

Do not use expressions which rely on implicit conversion of an operand.

10.8

High Integrity CPP Rule

Ensure expressions used in assertions are free from side-effects.

10.9

High Integrity CPP Rule

Do not code side effects into the right-hand operands of '&&', '||', 'sizeof' or 'typeid'.

10.10

High Integrity CPP Rule

Avoid statements that have no side effects.

10.11

High Integrity CPP Rule

Do not apply the following bitwise operators to signed operands: shift operators ('<<', '>>'), bitwise AND ('&'), exclusive OR ('^') and inclusive OR ('|').

10.12

High Integrity CPP Rule

Validate arguments to be used in shift operators.

10.13

High Integrity CPP Rule

Do not mix signed and unsigned data items in the same expression.

10.14

High Integrity CPP Rule

Do not mix arithmetic precision in expressions.

10.15

High Integrity CPP Rule

Do not write code that expects floating point calculations to yield exact results.

10.16

High Integrity CPP Rule

Do not use the increment operator ('++') on a variable of type 'bool'.

10.17

High Integrity CPP Rule

Guard both division and remainder operations by a test on the right hand operand being non-zero.

10.18

High Integrity CPP Guideline

Guard the modulus operation to ensure that both arguments are non-negative.

10.19

High Integrity CPP Rule

Do not use the comma operator.

10.20

High Integrity CPP Rule

Do not use the ternary operator (?:) in expressions.

10.21

High Integrity CPP Rule

Apply unary minus to operands of signed type only.


HICPP VERSION 2.4  http://www.codingstandard.com   Copyright: © 2007 THE PROGRAMMING RESEARCH GROUP