Dynamically-allocated memory via new and malloc are guaranteed to be aligned properly for a machine, while non-dynamically-allocated memory is not. Where "non-dynamically-allocated memory" is automatic memory where objects are allocated on the stack using placement new on top of a char buffer. The char buffer may or may not be aligned, which can be a latent bug, or a cause of a problem when porting.
Reference: Exceptional C++ by Herb Sutter. Addison-Wesley, 1999, p. 117.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment