PVS-StudioWarnings

PVS-Studio warning V509 for Geant4

Nov 17th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. template <class T> G4THitsCollection<T>::~G4THitsCollection()
  2. {
  3.   if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ =
  4.     new G4Allocator<G4HitsCollection>;
  5.   std::vector<T*> * theHitsCollection =
  6.     (std::vector<T*>*)theCollection;
  7.   //theHitsCollection->clearAndDestroy();
  8.   for(size_t i=0;i<theHitsCollection->size();i++)
  9.   { delete (*theHitsCollection)[i]; }
  10.   theHitsCollection->clear();
  11.   delete theHitsCollection;
  12. }
  13.  
  14. This suspicious code was found in Geant4 project by PVS-Studio static code analyzer.
  15. Warning message is:
  16. V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. _G4FR-archive g4thitscollection.hh 161
  17.  
  18. 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