From owner-freebsd-hackers Sat Feb 15 02:26:53 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id CAA15021 for hackers-outgoing; Sat, 15 Feb 1997 02:26:53 -0800 (PST) Received: from pat.idt.unit.no (0@pat.idt.unit.no [129.241.103.5]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id CAA15011 for ; Sat, 15 Feb 1997 02:26:45 -0800 (PST) Received: from idt.unit.no (27959@vier.idt.ntnu.no [129.241.103.4]) by pat.idt.unit.no (8.8.5/8.8.5) with ESMTP id LAA23547; Sat, 15 Feb 1997 11:26:40 +0100 (MET) Message-Id: <199702151026.LAA23547@pat.idt.unit.no> To: eivind@dimaga.com Cc: hackers@freebsd.org Subject: Re: NULL as ((void*)0) (was Re: strlen() question) In-Reply-To: Your message of "Sat, 15 Feb 1997 01:48:58 +0100" References: <3.0.32.19970215014856.00c14100@dimaga.com> X-Mailer: Mew version 1.06 on Emacs 19.34.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Date: Sat, 15 Feb 1997 11:26:39 +0100 From: "Arne H. Juul" Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > BTW: I just got another idea - if we can turn the definition of NULL > between ((void*)0) and 0 we can detect if NULL is abused if compiling on a > machine with different sizeof(void*) and sizeof(int). If used correctly, > code will be equal no matter what the definition - if used incorrectly, > different code should result. This can provide fairly automatic detection > of errors, provided we have two different builds. I think this is a good idea too, but it isn't really neccessary to change anything in the main source tree for this (though it would make it easier if there was just one place to change, of course). I have done a make world with (most) of the #define's for NULL set to ((void *)0) and have found a few minor bugs already (23% done). PR will follow. BTW, as far as I can see from my C standard the rules for NULL are pretty lax; both (1-1) and something like typedef enum { __ournull=0 } __dummynull; #define NULL __ournull should be legal. - Arne H. J.