Path: utzoo!attcan!uunet!cs.utexas.edu!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps From: flaps@dgp.toronto.edu (Alan J Rosenthal) Newsgroups: comp.lang.c Subject: Re: 'Possibly Incorrect Assignment' warnings from { obscure compiler } Message-ID: <1989Nov25.141758.28088@jarvis.csri.toronto.edu> Date: 25 Nov 89 19:17:58 GMT References: <256D8362.18B@marob.masa.com> <1989Nov25.134246.16025@virtech.uucp> Lines: 21 >daveh@marob.masa.com (Dave Hammond) writes: >> Should I change all such assignments to include an additional set of parens? cpcahil@virtech.uucp (Conor P. Cahill) writes: >This may or may not quiet the compiler, but it does nothing to assure the >reader of the intended operator. On the contrary, I've seen this exact practice recommended, here and elsewhere, and now use it all the time. I think a good way to think of it is that you never directly test the assignment as an expression, but you can make it into a more complicated expression in any way you like, including just parenthesizing an extra level. Putting in a "!= 0" is especially bad if the value is conceptually boolean, because then you are using a double negative, which is always confusing. ajr -- "Learning algorithms from Knuth is almost as bad as learning physics from Newton in the Latin original." -- Jeffrey Kegler