Representation of NULL and 0.0 (was Re: Zero Length Arrays ...)

Karl Heuer karl at haddock.ima.isc.com
Tue Dec 19 06:35:54 AEST 1989


In article <545 at mwtech.UUCP> martin at mwtech.UUCP (Martin Weitzel) writes:
>Wouldn't it have been wise to add another 'calloc' for floating
>types and NULL pointers, as the initializing feature of calloc
>is weak in this respect?

You still wouldn't have a way to allocate a zeroed struct of mixed types.

Personally, I think a wiser move would be to get rid of calloc(), since its
initializing feature is largely useless and misleading (and since its other
"feature", namely multiplying the two arguments together, can be done just as
easily and probably more efficiently at the caller's end).  I suspect that the
Commitee generally agrees, but was forced to keep calloc() for historical
reasons.

>Now, how is the situation with statically allocated data...?

The pANS requires that a static-duration datum not covered by an explicit
initializer (or an automatic-duration datum which is part of an initialized
aggregate but beyond the end of the explicit initializer, K&R2 to the contrary
notwithstanding) must have an initial value of a properly-typed zero.  Thus,
a non-VAXlike implementation cannot simply put all uninitialized objects into
a "bss segment".  (But it could sort them by type and have an "all-bits-zero
segment", a "floating-point zero space", etc. if it's worth the effort.)

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