PVS-StudioWarnings

PVS-Studio warning V567 for VirtualBox

Nov 20th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. template<class C> class ConsoleEventBuffer
  2. {
  3. public:
  4.   ....
  5.   C get()
  6.   {
  7.     C c;
  8.     if (full || curg != curp)
  9.     {
  10.       c = buf[curg];
  11.       ++curg %= sz;             //<==
  12.       full = false;
  13.     }
  14.     return c;
  15.   }
  16. ....
  17. };
  18.  
  19. This suspicious code was found in VirtualBox project by PVS-Studio static code analyzer.
  20. Warning message is:
  21. V567 Undefined behavior. The 'curg' variable is modified while being used twice between sequence points. consoleevents.h 75
  22.  
  23. 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