This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: suggest parentheses around assignment used as truth value


> 
> 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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]