malloc(0) returns an invalid address

Richard Tobin richard at inf.ed.ac.uk
Thu Dec 2 03:30:27 PST 2004


> malloc() is required to return memory aligned for any fundamental C
> type regardless of the amount of memory allocated (i.e. malloc(1) isn't
> permitted to return an odd address on hardware where types larger than
> (char) must be aligned).

How could a conforming program tell the difference?

(And so, why isn't it legal under the as-if rule?)

-- Richard


More information about the freebsd-current mailing list