Path: utzoo!mnetor!uunet!husc6!think!bloom-beacon!tut.cis.ohio-state.edu!im4u!ut-sally!utah-cs!utah-gr!uplherc!sp7040!obie!wes From: wes@obie.UUCP (Barnacle Wes) Newsgroups: comp.lang.c Subject: Re: == vs = Message-ID: <130@obie.UUCP> Date: 8 Apr 88 16:26:55 GMT References: <11216@brl-adm.ARPA> <2111@chinet.UUCP> <4403@garfield.UUCP> <226@hotlr.ATT> Organization: the Well of Souls Lines: 22 Summary: = is sometimes valid in if () In article <226@hotlr.ATT>, dkc@hotlr.ATT (Dave Cornutt) writes: > [...] D is another matter; catching the > accidental misapplication of "=" in "if" statements would be worth it. The one thing that everyone seems to have forgotten in this discussion is that `=' is NOT always invalid in and if clause: volatile short *statreg = (short *) 0x00FFC000L; ... short status; ... if (status = *statreg) { do something with status; } Code like this would (perhaps) be used for polling hardware status registers. Remember, C is supposed to be a general-purpose language! -- /\ - "Against Stupidity, - {backbones}! /\/\ . /\ - The Gods Themselves - utah-cs!utah-gr! / \/ \/\/ \ - Contend in Vain." - uplherc!sp7040! / U i n T e c h \ - Schiller - obie!wes