Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!crdgw1!crdos1!davidsen From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) Newsgroups: comp.lang.c Subject: Re: This one bit me today Message-ID: <832@crdos1.crd.ge.COM> Date: 5 Oct 89 15:17:54 GMT References: <2432@hub.UUCP> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: GE Corp R&D Center Lines: 27 In article <2432@hub.UUCP>, dougp@voodoo.ucsb.edu writes: | int a=1,b=2,*p=&a,c; | c=b/*p; | | First real flaw in the C grammer I have found. This is a good example, and I thank you. I have added something similar to my list of things to think about in the pointers section of my C course notes. It pops up in macros from time to time. Consider: #define xavg(m) (sum+3)/m Macros like this work fine until someone makes the arg a pointer deref, in which case the compiler screams and the programmer can't see the error. It's even worse if someone makes a mistake like this in a system header file... Kruft = xavg(*misc_err)+2; or even worse Kruft = xavg(*misc_err)+2 /* ruft constant */; which gives no warning but a wrong answer. -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon