Re: ANSI C clarifications, with citations (was Re: [patch-2.4

Olivier Galibert (galibert@pobox.com)
Tue, 27 Jun 2000 14:36:13 -0400


On Tue, Jun 27, 2000 at 12:05:23PM -0400, Sandy Harris wrote:
> > > > 7. You can freely cast between any two pointer types
>
> Cast a char * to int * on any architecture with strong alignmenmt
> restrictions and watch your code commit messy suicide.

No. It is "cast a char * to int * _and_dereference_it_". He never
told about dereferencing. Freely casting between different pointers
types works perfectly on most if not all modern[1] architectures, was
heavily used before the time of void * (look at the pre-ISO malloc()
prototype), and is still in heady use in C code that tries to mimic OO
abstraction in particular.

OG.

[1] Emphasis on modern. Tagged pointers are gone.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/