Problem 1277

Summary: G4Event::operator= should be hidden
Product: Geant4 Reporter: Tom Roberts <tjrob>
Component: eventAssignee: asai
Status: RESOLVED FIXED    
Severity: minor    
Priority: P5    
Version: 9.4   
Hardware: All   
OS: All   

Description Tom Roberts 2012-01-11 21:58:17 CET
The default operator= does not do the right thing for G4Event. Ditto for the default copy constructor. They should be declared private and left unimplemented.

My code has been using G4Event::operator= since before 1997 (before Geant4 5.2). I have never seen a problem with it on Windows, Linux, or Mac, until I tried building in 64-bit mode (geant4 9.4 patch03). Obviously I was just lucky. Fortunately I have regression tests that caught its effects.

This probably applies to G4PrimaryVertex as well, and possibly G4PrimaryParticle. It might apply to every class using G4Allocator. It almost certainly applies to any class that references other objects using pointers. You might want to consider an across-the-board hiding of these two routines in every class that does not explicitly implement them (that is recommended in at least one book on advanced C++ coding style).

Changing my code to avoid G4Event::operator= makes it pass all regression tests in 64-bit mode, except for a problem with Root (not a Geant4 problem).
Comment 1 asai 2012-03-07 09:02:19 CET
Thanks for reporting this. Fix will be included in the coming patch release.