Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!steinmetz!davidsen From: davidsen@steinmetz.steinmetz.UUCP (William E. Davidsen Jr) Newsgroups: comp.unix.xenix Subject: Re: Microport Users' Group Bug List (LONG) Message-ID: <6819@steinmetz.steinmetz.UUCP> Date: Mon, 27-Jul-87 13:41:58 EDT Article-I.D.: steinmet.6819 Posted: Mon Jul 27 13:41:58 1987 Date-Received: Tue, 28-Jul-87 04:22:31 EDT References: <166@qetzal.UUCP> <157@hobbes.UUCP> <245@ddsw1.UUCP> Reply-To: davidsen@kbsvax.steinmetz.UUCP (William E. Davidsen Jr) Organization: General Electric CRD, Schenectady, NY Lines: 43 In article <245@ddsw1.UUCP> karl@ddsw1.UUCP (Karl Denninger) writes: >In article <157@hobbes.UUCP>, root@hobbes.UUCP (John Plocher) writes: >> ... deleted stuff about printing NULL with %s in printf ... >Hmmm... Some things to consider: >a) NULL is declared in large model programs to be '0L' (look in the > header file) This is kind of a kluge. The ANSI standard proposes making this "(void *) 0" which works in all models. >b) (char *) variable, where variable contains 0, works in this > situation. (char *) NULL does not. Peculiar to your machine. Neither work on machines here. >c) I am *not* passing NULL, but rather a POINTER to it. The value > pointed TO at that location should BE the null! Regardless of what you think you are doing, you are passing the value 0L cast to a pointer to char. To pass a pointer to NULL you need to say "&NULL" which blatently won't work because NULL is a constant, not a variable. > >Will be more than happy to eat my bug report if there's a good reason why >the cast which I included does not produce the desired result -- especially >if someone can explain why example (b) works! Hope you're not counting calories, and I'm sure others will also help correct your perception of how casts work. > >Karl Denninger UUCP : ...ihnp4!ddsw1!karl >Macro Computer Solutions Dial : +1 (312) 566-8909 (300-1200) >"Quality solutions at a fair price" Voice: +1 (312) 566-8910 (24 hrs) It seems that the problem here is that the printf version being used does not recognize NULL and protect itself. When it tries to go indirect through the NULL pointer it gets an address which is not valid, and thereby a segmentation violation. -- bill davidsen (wedu@ge-crd.arpa) {chinet | philabs | sesimo}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me