PVS-StudioWarnings

PVS-Studio warning V547 for CLucene

Nov 18th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. class Arrays
  2. {
  3.   ....
  4.    bool equals( class1* val1, class2* val2 ) const{
  5.      static _comparator comp;
  6.      if ( val1 == val2 )
  7.        return true;
  8.      size_t size = val1->size();
  9.      if ( size != val2->size() )
  10.        return false;
  11.      _itr1 itr1 = val1->begin();
  12.      _itr2 itr2 = val2->begin();
  13.      while ( --size >= 0 ){
  14.        if ( !comp(*itr1,*itr2) )
  15.          return false;
  16.        itr1++;
  17.        itr2++;
  18.      }
  19.    return true;
  20.   }
  21.   ....
  22. }
  23.  
  24. This suspicious code was found in CLucene project by PVS-Studio static code analyzer.
  25. Warning message is:
  26. V547 Expression '-- size >= 0' is always true. Unsigned type value is always >= 0. arrays.h 154
  27.  
  28. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment