64-bit NULL: a followup

Marcel Moolenaar marcel at xcllnt.net
Sat Nov 29 09:36:11 PST 2003

On Sun, Nov 30, 2003 at 12:40:41AM +1100, Bruce Evans wrote:
> >
> > The bogusness doesn't increase if we're looking at widths. It actually
> > reduces. The FreeBSD runtime is either ILP32 or LP64. Hence, defining
> > NULL as long is better than defining it as int. For those running
> > IP32L64, NULL can trivially be redefined as int.
> It could be MD in all cases to hide bugs in a MD way.

Yes. This corresponds to MD behaviour of gcc. On alpha, amd64 and
sparc64 gcc widens NULL to 64 bit for arguments that have to be
passed on the stack (still in the context of variadic functions).
On ia64 gcc does not do that. The end result is that the use of NULL
(when defined as 0) without cast works for the first 8 arguments,
because those are passed in registers, but fail for all subsequent
arguments. The widening on the other platforms already hide bugs,
but at least create consistent behaviour. On ia64 the behaviour is
inconsistent, but AFAICT correct from a standards point of view.
Nonetheless utterly bogus behaviour from usability and portability
points of view.

 Marcel Moolenaar	  USPA: A-39004		 marcel at xcllnt.net

More information about the freebsd-standards mailing list