Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!homxb!mtuxo!mtune!codas!uflorida!gatech!itm!danny From: danny@itm.UUCP (Danny) Newsgroups: comp.sources.bugs Subject: Re: pointer checking Keywords: 16 bits vs 32 bits Message-ID: <1204@itm.UUCP> Date: 17 Feb 88 15:04:11 GMT References: <228@gandalf.littlei.UUCP> Reply-To: danny@itm.UUCP (Danny) Organization: In Touch Ministries, Atlanta, GA Lines: 48 In article <228@gandalf.littlei.UUCP> martin@littlei.UUCP (martin) writes: ~... ~sizeof(ptr) != sizeof(int). I know that C does not gripe if Yes, indeed, it is wrong to assume that sizeof (ptr) == sizeof (int), BUT: read on! ~Example: ~ ~char *ptr; ~ ~if (ptr) { /* WRONG !!!!!! */ ~ do something ~} Would you expect a C compiler to generate erroneous code for the following? char a; int b; long c; double d; if (a) { ... if (b) { ... if (c) { ... if (d) { ... The compiler knows exactly what size each of the above types is. Pointers, as far as comparison goes, are exactly the same. Any compiler that doesn't properly compile char *p; if (p) { do something; } is broken. The compiler knows the size of the pointer, and _should_ compare against the same size of a constant zero. Danny -- Daniel S. Cox (seismo!gatech!itm!danny)