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: Nathan Sidwell <nathan at cs dot bris dot ac dot uk>
- Subject: Re: suggest parentheses around assignment used as truth value
- From: Richard Earnshaw <rearnsha at arm dot com>
- Date: Fri, 03 Jul 1998 10:23:42 +0100
- Cc: egcs at cygnus dot com
- Cc: rearnsha at sun52 dot arm dot com
- Organization: Advanced RISC Machines Ltd.
- Reply-To: richard dot earnshaw at arm dot com
>
> It's rather hard to double the parentheses in error, and the form does
> visually stand out.
>
It's very easy to double the parentheses in error. You just have to have
the erroneous code inside a macro.
Somewhat simple I know, but:
#define COMPARE(X,Y) ((X)=(Y)) /* Should be == */
...
if (COMPARE(p,q)) {...} /* Should get a warning, but doesn't */
Richard.