https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70800

--- Comment #10 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Eric Gallager from comment #4)
> (In reply to David Binderman from comment #3)
> > I just discovered that clang++ can be made to find this bug by
> > adding flag -Wtautological-compare.
> > 
> > jan22a.cc:6:17: warning: bitwise comparison always
> >       evaluates to false [-Wtautological-compare]
> >         if ((n & 0x30) == 1)
> >             ~~~~~~~~~~~^~~~
> 
> I think Marek enhanced -Wtautological-compare to catch cases like this, in
> which case bug 71852 is related

I had a quick look at Marek's patch and bearing in mind
I am a complete novice at gcc source code, these lines look suspicious:

+  /* For BIT_AND only warn if (CST2 & CST1) != CST1, and
+     for BIT_OR only if (CST2 | CST1) != CST1.  */
+  if (res == cst)
+    return;

so I suspect the comparison operator of ">" makes sure
the warning cannot be produced.

Reply via email to