Versions Compared

Key

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

Different alignments are possible for different types of objects. If the type checking system is overridden by an explicit cast , or the pointer is converted to void * and then to a different type, the alignment of an object may be changed. As a result, if a pointer to one object type is converted to a pointer to a different object type, the second object type must not require stricter alignment than the first.

...

One solution is to ensure that loop_ptr points to an object returned by malloc(), because this object is guaranteed to be aligned properly for any need. However, this is a subtlety that is easily missed when the program is modified in the future. It is cleaner to let the type system document the alignment needs.

...

Accessing a pointer or an object that is no longer on the correct access boundary can cause a program to crash , or give wrong information, or may cause slow pointer accesses (if the architecture allows misaligned accesses).

...