A cast pointer is NOT an lvalue!? (ANSI C)

Karl Heuer karl at haddock.ima.isc.com
Tue Oct 18 10:01:44 AEST 1988


In article <14005 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>In article <482 at midgard.mn.org> dal at midgard.mn.org (Dale Schumacher) asks:
>>... If an implementation stores different object types in different
>>areas of memory, then wouldn't that fail also?  How would one implement
>>malloc() on such a machine?
>
>The short answer is `one would not'.  The long one is that maybe it
>would work if the compiler recognised allocation calls (malloc, calloc)

On such an implementation, malloc() is not your only problem.  What about a
pointer which is (legally) cast to a less strictly aligned type and back
again?  What about a struct containing two different object types?

I think it's safe to say that no C implementation would depend on such type
segregation.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list