Advertisement
PVS-StudioWarnings

PVS-Studio warning V501 for Clang

Nov 25th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. bool EdgeBuilder::containsLocation(
  2.   const PathDiagnosticLocation &Container,
  3.   const PathDiagnosticLocation &Containee)
  4. {
  5.   ...
  6.   return (ContainerBegLine <= ContaineeBegLine &&
  7.           ContainerEndLine >= ContaineeEndLine &&
  8.           (ContainerBegLine != ContaineeBegLine ||
  9.            SM.getExpansionColumnNumber(ContainerRBeg) <=
  10.            SM.getExpansionColumnNumber(ContaineeRBeg)) &&
  11.           (ContainerEndLine != ContaineeEndLine ||
  12.            SM.getExpansionColumnNumber(ContainerREnd) >=
  13.            SM.getExpansionColumnNumber(ContainerREnd)));
  14. }
  15.  
  16. The ContaineeREnd variable should have been used in the last line instead of ContainerREnd. You don't see the difference? Spell the words.
  17.  
  18. This suspicious code was found in Clang project by PVS-Studio static code analyzer.
  19. Warning message is:
  20. V501 There are identical sub-expressions 'SM.getExpansionColumnNumber(ContainerREnd)' to the left and to the right of the '>=' operator. clangStaticAnalyzerCore bugreporter.cpp 925
  21.  
  22. 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
Advertisement