Problem 1131

Summary: Useless code in G4QContent constructor
Product: Geant4 Reporter: Marc Paterno <paterno>
Component: processes/hadronic/models/chiral_inv_phase_spaceAssignee: dennis.herbert.wright
Status: RESOLVED FIXED    
Severity: normal    
Priority: P5    
Version: 9.3   
Hardware: All   
OS: All   

Description Marc Paterno 2010-07-29 18:50:15 CEST
The body of the constructor for G4QContent that takes 6 ints contains code with no effect, and which an optimizer is almost sure to eliminate:

 56 // Initialize by  the full quark content
 57 G4QContent::G4QContent(G4int d, G4int u, G4int s, G4int ad, G4int au, G4int as):
 58   nD(d),nU(u),nS(s),nAD(ad),nAU(au),nAS(as)
 59 {
 60   if(d<0||u<0||s<0||ad<0||au<0||as<0)
 61   {
 62 #ifdef erdebug
 63     G4cerr<<"***G4QContent:"<<d<<","<<u<<","<<s<<","<<ad<<","<<au<<","<<as<<G4endl;
 64 #endif
 65     if(d<0) ad-=d;
 66     if(u<0) au-=u;
 67     if(s<0) as-=s;
 68     if(ad<0) d-=ad;
 69     if(au<0) u-=au;
 70     if(as<0) s-=as;
 71   }
 72 }

The variables ad, au, as, e, u, and s that are modified in the conditional logic are all local (not the member data of the object being constructed), and thus the optimizer will do away with the entire conditional code.

It seems unlikely that this was the intention of the author.
Comment 1 dennis.herbert.wright 2010-09-02 20:10:21 CEST
Hi Marc,

   Thanks.  I'll take a look.

Dennis
Comment 2 dennis.herbert.wright 2010-11-11 19:30:51 CET
Your fix has been made and will be included in the 9.4 release.

Dennis