Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added related guideline TR17961

Modifying a variable through a pointer of an incompatible type can lead to unpredictable results. This is often caused by a violation of aliasing rules. C11, Section 6.5, paragraph 7 [ISO/IEC 9899:19992011] specifies those circumstances in which an object may or may not be aliased.

...

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

EXP39-C

medium

unlikely

high

P2

L3

Related Guidelines

ISO/IEC 9899:19992011 Section 6.5, "Expressions"

ISO/IEC TR 17961 Accessing an object through a pointer to an incompatible type [ptrcomp]

Bibliography

GCC Known Bugs C bugs, Aliasing issues while casting to incompatible types
GCC Manual
[Walfridsson 2003] Krister Walfridsson. Aliasing, pointer casts and gcc 3.3 Aliasing issue. August, 2003.
[Acton 2006] Mike Acton. Understanding Strict Aliasing. June 01, 2006.

...