Common malloc/free practice violates ANSI standard ?

Doug Gwyn gwyn at smoke.BRL.MIL
Mon Oct 16 13:29:33 AEST 1989


In article <1989Oct14.043811.669 at anucsd.oz> bdm at anucsd.oz (Brendan McKay) writes:
>Note that I'm not claiming the Standard is broken, only that the writers of
>the standard have accidentally ruled out a common coding practice.

No, we didn't -- any valid pointer can be converted to a pointer that
has less strict alignment and back, so that the result compares equal
to the original pointer, void* has the same alignment requirement as
char*, and converting a coarsely-aligned malloc() void* to OBJ* does
NOT result in adjustment of the alignment.  Apply ALL the relevant
constraints and you'll find that there is no problem with typical
malloc()/free() usage.



More information about the Comp.std.c mailing list