Problem 1277 - G4Event::operator= should be hidden
Summary: G4Event::operator= should be hidden
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: event (show other problems)
Version: 9.4
Hardware: All All
: P5 minor
Assignee: asai
URL:
Depends on:
Blocks:
 
Reported: 2012-01-11 21:58 CET by Tom Roberts
Modified: 2012-03-07 09:02 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
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.