[comp.unix.programmer] null pointers

scs@adam.mit.edu (Steve Summit) (04/01/91)

In article <6905@segue.segue.com> jim@segue.segue.com (Jim Balter) writes:
>...but note that many many programs use memset or calloc
>to clear arrays or structures that contain pointers.
>
>C implementations that use something other than a zero bit pattern for NULL
>pointers, aside from indicating bad judgement, are likely also to be
>non-conforming, if they use BSS or the equivalent for
>
>void	*foo[100000];
>
>since ANSI requires that it be the same as
>
>void	*foo[100000] = {0, ... repeated 100000 times};
>
>I really wouldn't recommend comp.lang.c as a high quality source.

I can't claim that comp.lang.c has a stellar signal/noise ratio,
but, as Usenet groups go, it is generally more reliable for
C-specific information than other groups.  Regular readers of
comp.lang.c know that:

	there are good reasons for an architecture's choosing to
	use a nonzero internal value for null pointers;

	it is invalid to use calloc or memset to fully initialize
	aggregates containing pointers (if it is desired to
	initialize the pointers to null pointers); and

	systems which use nonzero internal values for null
	pointers may not use zero-initialized segments
	(comparable to Unix' bss) for statically-allocated
	pointer data, but must emit explicitly initialized data
	segments.

All of these issues are discussed in the comp.lang.c Frequently
Asked Questions list.

                                            Steve Summit
                                            scs@adam.mit.edu