Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Similarly, comparing pointers gives the positions of the pointers relative to each other within the array. Subtracting or comparing pointers that do not refer to the same array can result in erroneous behavior.

It is acceptable to subtract or compare two member pointers within a single struct object, suitably cast, because any object can be treated as an array of unsigned char. However, when doing so remember to account for the effects of alignment and padding on the structure.

Comparison of pointers using == or != is always permitted; this rule only applies to the inequality operators (< <= > >=), as well as pointer subtraction.

Noncompliant Code Example (Arrays)

...