This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: suggest parentheses around assignment used as truth value
- To: richard dot earnshaw at arm dot com
- Subject: Re: suggest parentheses around assignment used as truth value
- From: Nathan Sidwell <nathan at cs dot bris dot ac dot uk>
- Date: Fri, 03 Jul 1998 09:27:09 +0100
- CC: egcs at cygnus dot com
- Organization: Computer Science Dept, Bristol University
- References: <199807021119.MAA19946@sun52.NIS.cambridge>
Richard Earnshaw wrote:
>
> Of course the parentheses are necessary in that case, but the meaning is
> obvious, and the compiler can tell that a warning is unnecessary.
>
> In my opinion, it's a bug if gcc doesn't emit a warning for
>
> if ((x = p())) {...}
>
> but does for
>
> if (x = p()) {...}
>
> since apart from an extra set of parentheses they are identical. Perhaps
> the warning should be changed to "suggest explicit comparison of
> assignment used as truth value".
I think it'd be a mistake to change the behaviour of this warning and
its inhibiting syntax. It's been that way on gcc for too long. I for one
would be annoyed -- and you can tell how picky I can be about warnings
from some of my other posts :-)
It's rather hard to double the parentheses in error, and the form does
visually stand out.
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
You can up the bandwidth, but you can't up the speed of light
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk