PVS-StudioWarnings

PVS-Studio warning V501 for SlimDX

Nov 20th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. ContainmentType BoundingBox::Contains(
  2.   BoundingBox box, BoundingSphere sphere )
  3. {
  4.   ....
  5.   if( box.Minimum.X + radius <= sphere.Center.X &&
  6.       sphere.Center.X <= box.Maximum.X - radius &&
  7.       box.Maximum.X - box.Minimum.X > radius    &&  <<<===
  8.       box.Minimum.Y + radius <= sphere.Center.Y &&
  9.       sphere.Center.Y <= box.Maximum.Y - radius &&
  10.       box.Maximum.Y - box.Minimum.Y > radius    &&
  11.       box.Minimum.Z + radius <= sphere.Center.Z &&
  12.       sphere.Center.Z <= box.Maximum.Z - radius &&
  13.       box.Maximum.X - box.Minimum.X > radius)       <<<===
  14.     return ContainmentType::Contains;
  15.   ....
  16. }
  17.  
  18. This suspicious code was found in SlimDX project by PVS-Studio static code analyzer.
  19. Warning message is:
  20. V501 There are identical sub-expressions 'box.Maximum.X - box.Minimum.X > radius' to the left and to the right of the '&&' operator. boundingbox.cpp 94
  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