PVS-StudioWarnings

PVS-Studio warning V519 for Geant4

Nov 20th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. G4double G4RKFieldIntegrator::CalculateTotalEnergy(
  2.   const G4KineticTrackVector& Barions)
  3. {
  4.   G4double Etot = 0;
  5.   ....
  6.   for(G4int c2 = c1 + 1; c2 < nBarion; c2++)
  7.   {
  8.     ....
  9.     //  Esk2
  10.     Etot += t1*std::pow(Alpha/pi, 3/2)*std::exp(-Alpha*r12*r12);
  11.  
  12.     // Eyuk
  13.     Etot += ....;
  14.  
  15.     // Ecoul
  16.     Etot += 1.44*p1->GetDefinition()->GetPDGCharge()*
  17.             p2->GetDefinition()->GetPDGCharge()/r12*
  18.             Erf(std::sqrt(Alpha)*r12);
  19.  
  20.     // Epaul
  21.     Etot = 0;
  22.     ....
  23.   }
  24.   ....
  25. }
  26.  
  27. This suspicious code was found in Geant4 project by PVS-Studio static code analyzer.
  28. Warning message is:
  29. V519 The 'Etot' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 80, 83. _G4processes-archive g4rkfieldintegrator.cc 83
  30.  
  31. 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