Problem 660

Summary: GEANT4 does not compile with gcc 3.4.1
Product: Geant4 Reporter: oberlack
Component: global/managementAssignee: Gabriele Cosmo <Gabriele.Cosmo>
Status: RESOLVED INVALID    
Severity: critical CC: oberlack, rickard
Priority: P2    
Version: 6.2   
Hardware: Other   
OS: Linux   

Description oberlack 2004-08-13 13:36:05 CEST
We recently upgraded the gcc compiler from 2.96 to the current version 3.4.1.
Parts of GEANT4 do not compile, due to a problem in G4Allocator.hh, line 165.
The error message is "aggregate value used where an integer was expected"
Any ideas? Thank you.
Comment 1 rickard 2004-08-23 03:17:59 CEST
I changed G4Allocator.hh to work for me, by replacing the following lines:

  // The gcc-3.1 compiler will complain and not correctly handle offsets
  // computed from non-POD types. Pointers to member data should be used
  // instead.  This C++ feature seems not to work on earlier versions of
  // the same compiler.
  //
  #if (__GNUC__==3) && (__GNUC_MINOR__>0)
    Type G4AllocatorUnit<Type>::*pOffset = &G4AllocatorUnit<Type>::fElement;
    fUnit = (G4AllocatorUnit<Type> *) ((char *)anElement - size_t(pOffset));
  #else
    fUnit = (G4AllocatorUnit<Type> *)
            ((char *) anElement - offsetof(G4AllocatorUnit<Type>, fElement));
  #endif


with the following:

  fUnit = (G4AllocatorUnit<Type> *)
       ((char *) anElement + ((char *) fUnit - (char*) &(fUnit->fElement)));

I put a patchfile at http://rickard.holmberg.homeip.net/G4Allocator.patch
Comment 2 Gabriele Cosmo 2004-08-25 12:20:59 CEST
Geant4 6.2 is NOT ported on gcc-3.4.X. See the release notes for the list of
compilers supported.
Porting on the new gcc compiler will be implemented for future releases, where
a new implementation of G4Allocator will be provided.
Comment 3 Gabriele Cosmo 2004-10-13 01:48:59 CEST
*** Bug 678 has been marked as a duplicate of this bug. ***
*** 'Gabriele.Cosmo@cern.ch' will be responsible for bug 678. ***