Advertisement
PVS-StudioWarnings

PVS-Studio warning V517 for Geant4

Nov 21st, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. void G4VTwistSurface::GetBoundaryLimit(G4int areacode,
  2.                                        G4double limit[]) const
  3. {
  4.   ....
  5.   if (areacode & sC0Min1Max) {
  6.      limit[0] = fAxisMin[0];
  7.      limit[1] = fAxisMin[1];
  8.   } else if (areacode & sC0Max1Min) {
  9.      limit[0] = fAxisMax[0];
  10.      limit[1] = fAxisMin[1];
  11.   } else if (areacode & sC0Max1Max) {
  12.      limit[0] = fAxisMax[0];
  13.      limit[1] = fAxisMax[1];
  14.   } else if (areacode & sC0Min1Max) {
  15.      limit[0] = fAxisMin[0];
  16.      limit[1] = fAxisMax[1];
  17.   }
  18.   ....
  19. }
  20.  
  21. Most likely this is what should be written here: if (areacode & sC0Min1Min) { limit[0] = fAxisMin[0]; limit[1] = fAxisMin[1]; }
  22.  
  23. This suspicious code was found in Geant4 project by PVS-Studio static code analyzer.
  24. Warning message is:
  25. V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 793, 802. G4specsolids g4vtwistsurface.cc 793
  26.  
  27. 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