[PATCH] D13643: [Sema] Warn on ternary comparison

Daniel Marjamäki via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 20 22:32:20 PDT 2015


danielmarjamaki added a comment.

I tested this on 2199 debian projects.. and got 16 warnings.

  ftp://ftp.se.debian.org/debian/pool/main/t/tf5/tf5_5.0beta8.orig.tar.gz
  expr.c:738:22: warning: comparisons such as 'a < b != c' do not have their mathematical meaning [-Wparentheses]
          if (neg0 == neg1 && sum<0 != neg0) {
                              ^~~~~~~~~~~~~

I guess it could be intentional. I haven't looked in the real code.

  ftp://ftp.se.debian.org/debian/pool/main/m/medusa/medusa_2.1.1.orig.tar.gz
  cvs.c:111:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  ftp.c:140:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  imap.c:143:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 2) )
           ^~~~~~~~~~~~~~
  mysql.c:135:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  nntp.c:110:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  pcanywhere.c:133:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  pop3.c:133:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  rexec.c:95:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  rlogin.c:94:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  rsh.c:96:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  smtp.c:135:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  smtp-vrfy.c:114:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  snmp.c:154:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  telnet.c:143:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~
  vmauthd.c:109:10: warning: comparisons such as 'a <= b <= c' do not have their mathematical meaning [-Wparentheses]
    if ( !(0 <= argc <= 3) )
           ^~~~~~~~~~~~~~

these are surely true positives.


http://reviews.llvm.org/D13643





More information about the cfe-commits mailing list