PVS-StudioWarnings

PVS-Studio warning V501 for Clang

Nov 13th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. AsmToken AsmLexer::LexLineComment() {
  2.   // FIXME: This is broken if we happen to a comment
  3.   // at the end of a file, which was .included, and
  4.   // which doesn't end with a newline.
  5.   int CurChar = getNextChar();
  6.   while (CurChar != '\n' && CurChar != '\n' && CurChar != EOF)
  7.     CurChar = getNextChar();
  8.   ...
  9. }
  10.  
  11. Most likely this is what should be written here: (CurChar != '\n' && CurChar != '\r' && CurChar != EOF).
  12.  
  13. This suspicious code was found in Clang project by PVS-Studio static code analyzer.
  14. Warning message is:
  15. V501 There are identical sub-expressions to the left and to the right of the '&&' operator: CurChar != '\n' && CurChar != '\n' LLVMMCParser asmlexer.cpp 149
  16.  
  17. 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