commom malloc/free practice breaks standard - author strikes back

T. William Wells bill at twwells.com
Tue Oct 24 10:27:14 AEST 1989


In article <420 at cpsolv.UUCP> rhg at cpsolv.uucp (Richard H. Gumpertz) writes:
: [nonsense, because he either has an older standard or has't read it very
: carefully.]

I decided to collect the sections of the standard relevant to the
debate. Here they are:

3.1.2.5:

"A pointer to void shall have the same representation and
alignment requirements as a pointer to a character type."

3.2.2.3:

"A pointer to void may be converted to or from a pointer to any
incomplete or object type. A pointer to any incomplete or object
type may be converted to a pointer to void and back again; the
result shall compare equal to the original pointer."

3.3.4:

"A pointer to an object or incomplete type may be converted to a
pointer to a different object type or a different incomplete type.
The resulting pointer might not be valid if it is improperly
aligned for the type pointed to. It is guaranteed, however, that
a pointer to an object of a given alignment may be converted to a
pointer to an object of the same alignment or a less restrictive
alignment and back again; the result shall compare equal to the
original pointer. (An object that has character type has the
least strict alignment.)"

3.3.9:

"If two pointers to object or incomplete types compare equal,
they point to the same object. If two pointers to functions
compare equal, they point to the same function. If two pointers
point to the same object or function, they compar equal."

4.10.3:

"The pointer returned if the allocation succeeds is suitably
aligned so that it may be assigned to a pointer of any type of
object and then used to access such an object in the space
allocated (until the space is explicitly freed or reallocated).
Each such allocation shall yield a pointer to an object disjoint
from any other object. The pointer returned points to the start
(lowest byte address) of the allocated space."

---
Bill                    { uunet | novavax | ankh | sunvice } !twwells!bill
bill at twwells.com



More information about the Comp.lang.c mailing list