From mboxrd@z Thu Jan 1 00:00:00 1970 From: Branko Cibej To: Marc Rouaix Cc: egcs@cygnus.com Subject: Re: suggest parentheses around assignment used as truth value Date: Wed, 01 Jul 1998 03:42:00 -0000 Message-id: <359A0FF9.5808853D@hermes.si> References: X-SW-Source: 1998-07/msg00027.html Marc Rouaix wrote: > I'd just like to register my opiniont that code like > > if (x = p()) {...} > > shouldn't generate a warning under gcc -Wall. What if you meant to write "if (x == p()) {...}"? Such bugs are usually very hard to find. > Even if you feel that code like this is obscure, It is _not_ obscure, it is in fact used quite often; therefore the possibility of a typo is large enough to warrant a warning. > the recommended > > if ((x = p())) {...} > > is just bizarre. Can you recommend a better way of telling the compiler that you know what you're doing? I mean, apart from the obvious x = p(); if (x) {...} Brane -- Branko Cibej HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia phone: (++386 61) 186 53 49 fax: (++386 61) 186 52 70