malloc vs calloc and invalid pointers

Doug Gwyn gwyn at smoke.ARPA
Mon Oct 3 13:31:30 AEST 1988


In article <827 at goofy.megatest.UUCP> djones at megatest.UUCP (Dave Jones) writes:
>Now for the other question: Is it guaranteed that the actual memory
>allocated (static, automatic, or malloc) for a variable foo is always
>at least sizeof(foo)?

No, under some circumstances an attempt to access some bytes of the
virtual object "foo" might fail.  For example, if "foo" is a structure
with a hole at the end.

>  /* Might the following "step on" char a or char z? */

No, the objects are non-overlapping as a consequence of several
constraints within the dpANS.



More information about the Comp.lang.c mailing list