Versions Compared

Key

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

...

Casting does not work as expected when optimization is turned on. This is often caused by a violation of aliasing rules, which are part of the ISO C standard.

Wiki Markup
C99 \[\[ISO/IEC 9899:1999\|AA. C References#ISO/IEC 9899-1999\|https://www.securecoding.cert.org/confluence/display/seccode/AA.+C+References#AA.CReferences-ISO%2FIEC98991999]\]  states that
\\

7. An object shall have its stored value accessed only by an lvalue expression that has one of
the following types: (78)

— a type compatible with the effective type of the object,
— a qualified version of a type compatible with the effective type of the object,
— a type that is the signed or unsigned type corresponding to the effective type of the
object,
— a type that is the signed or unsigned type corresponding to a qualified version of the
effective type of the object,
— an aggregate or union type that includes one of the aforementioned types among its
members (including, recursively, a member of a subaggregate or contained union), or
— a character type.

/78) The intent of this list is to specify those circumstances in which an object may or may not be aliased./

...