Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: For C Experts

2006-03-31 by Thiadmer Riemersma (ITB CompuPhase)

This is what "The C Programming Language" 2nd edition (Kernighan &
Ritchie) says (page 199):

"A pointer to one type may be converted to a pointer to another type.
The resulting pointer may cause addressing exceptions if the subject
pointer does not refer to an object suitably aligned in storage."

When casting pointers to another type, the programmer must keep an eye
on alignment. A compiler may use clever techniques to warn for
possible misalignment, but it is not required to do so.

Regarding the effort of examining all source code for type casts with
alignment problems, my opinion is that type casts should be used
sparingly. The requirement to "silence" the compiler with a type cast
already means that the compiler frowned upon the statement.

Thiadmer

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.