'Possibly Incorrect Assignment' warnings from { obscure compiler }

Alan J Rosenthal flaps at dgp.toronto.edu
Sun Nov 26 06:17:58 AEST 1989


>daveh at marob.masa.com (Dave Hammond) writes:
>> Should I change all such assignments to include an additional set of parens?

cpcahil at 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



More information about the Comp.lang.c mailing list