suggest parentheses around assignment used as truth value

Andreas Schwab schwab@issan.informatik.uni-dortmund.de
Wed Jul 1 02:51:00 GMT 1998


"Marc Rouaix" <rouaix@my-dejanews.com> writes:

|> 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 have a typo here?

|>  Even if
|> you feel that code like this is obscure, the recommended
|> 
|> if ((x = p())) {...}
|> 
|> is just bizarre.

Then write it as:

	x = p();
	if (x) {...}

-- 
Andreas Schwab                                      "And now for something
schwab@issan.informatik.uni-dortmund.de              completely different"
schwab@gnu.org



More information about the Gcc mailing list