Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!pacbell.com!ames!haven!umd5!jupiter.astro.umd.edu!jjk From: jjk@jupiter.astro.umd.edu (Jim Klavetter) Newsgroups: comp.lang.c Subject: unbelievable "simple" question/bug? Message-ID: <8331@umd5.umd.edu> Date: 28 Mar 91 06:06:47 GMT Sender: news@umd5.umd.edu Reply-To: jjk@astro.umd.edu (Jim Klavetter) Distribution: na Organization: U of Md., Astronomy Program Lines: 33 It isn't precedence or some side effect, it is just weird. I have the code fragment (a, b, c, integers) if(a-b-c>0) do ifstuff else do elsestuff When a=b=c=1 the above should translate to if(-1>0) and the elsestuff should get done. It doesn't. I tried putting parens around (a-b-c) (which should be unnecessaray) and it didn't make any difference. OK, now here is the real weird part: if I have the following: temp=a-b-c; if(temp>0) do ifstuff else do elsestuff it works as expected! Anybody want to tell me what I'm missing? Obviously, this really isn't the exact code, so I'll give a few more details which I don't think are relevant. I'm using gcc on a sun4 running sunos 4.1. "a" is really argc and "b" is really optind but I know that isn't relevant because I check their values (as well as "c") both before the if and in both branches and all three values don't change (as expected). Thanks for any help possible with this one. jjk@astro.umd.edu also for Athabasca and Reudi Jim Klavetter Astronomy UMD College Park, MD 20742