Path: utzoo!utgpu!water!watmath!clyde!rutgers!cmcl2!brl-adm!umd5!trantor.umd.edu!chris From: chris@trantor.umd.edu (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: regcmp() Message-ID: <2322@umd5.umd.edu> Date: 19 Feb 88 09:07:00 GMT References: <9@vsi.UUCP> <15100006@bucc2> Sender: ris@umd5.umd.edu Reply-To: chris@trantor.umd.edu (Chris Torek) Organization: University of Maryland, College Park Lines: 42 >>>The problem is with what you are passing. You are passing (char *)0 >>>instead of (char *)NULL. [(char *)0 and (char *)NULL are required to be the same!] >>Not if you cast it to "char *", it isn't! Passing "(char *)0" is quite >>sufficient, unless the compiler is horribly broken. [Guy Harris] In article <15100006@bucc2> brian@bucc2.UUCP writes: > Tsk, tsk, tsk. This statment is true if sizeof(int) == sizeof(pointer). >Not a good assumption to make, eh? I do a great deal of programming using >Microsoft C 5.0 on IBM PEE CEE's. In large model, pointers are four bytes >long. However, constant integer expessions are ints, and an int is only two >bytes long. NO! NO NO NO NO NO *grumble* Constant integer expressions are indeed ints. (char *)0 is not a constant integer expression, it is a constant expression of type `pointer to char'. Incidentally, Microsoft's definition of NULL as 0L is technically legal, but is a bad idea. It covers up code bugs in large model, but they still show in mixed model code. Once again: (char *)0 (char *)0L (char *)NULL are all identical in both value and type. `0' is a proper nil pointer of any type as long as it is in a context that coerces it to a pointer. Assignment, comparison, and casts provide context; function calls do not[*]. It is that simple. ----- [*] except when a prototype is in scope -- In-Real-Life: Chris Torek, Univ of MD Computer Science, +1 301 454 7163 (hiding out on trantor.umd.edu until mimsy is reassembled in its new home) Domain: chris@mimsy.umd.edu Path: not easily reachable