Gcc 3.4.6 and Optimization problem

Hi,

I was seeing error messages of the form:

[quote]/nfs/babar/CompMgt/desilva/niteFeb09/tmp/Linux26SL4_i386_gcc346/RecoDataK/RecoDataKCint.cc: At global scope:
/nfs/babar/CompMgt/desilva/niteFeb09/tmp/Linux26SL4_i386_gcc346/RecoDataK/RecoDataKCint.cc:3563: error: specialization of static const char* RecoGMatchK<RObj_I, GObj_I>::Class_Name() [with RObj_I = SvtRootClusterI, GObj_I = GTrackI] after instantiation
/nfs/babar/CompMgt/desilva/niteFeb09/tmp/Linux26SL4_i386_gcc346/RecoDataK/RecoDataKCint.cc:3563: error: prototype for static const char* RecoGMatchK<RObj_I, GObj_I>::Class_Name() [with RObj_I = SvtRootClusterI, GObj_I = GTrackI]' does not match any in classRecoGMatchK<SvtRootClusterI, GTrackI>’
/nfs/babar/CompMgt/desilva/niteFeb09/tmp/Linux26SL4_i386_gcc346/RecoDataK/RecoGMatchK.hh:101: error: candidate is: static const char* RecoGMatchK<RObj_I, GObj_I>::Class_Name() [with RObj_I = SvtRootClusterI, GObj_I = GTrackI]
/nfs/babar/CompMgt/desilva/niteFeb09/tmp/Linux26SL4_i386_gcc346/RecoDataK/RecoDataKCint.cc:3563: error: static const char* RecoGMatchK<RObj_I, GObj_I>::Class_Name() [with RObj_I = SvtRootClusterI, GObj_I = GTrackI]' andstatic const char* RecoGMatchK<RObj_I, GObj_I>::Class_Name() [with RObj_I = SvtRootClusterI, GObj_I = GTrackI]’ cannot be overloaded
[/quote]

which I eventually traced to using the -O flag in gcc 3.4.6. I see this in ROOT 5.10-00f and also 5.14-00b.

To reproduce the problem, I have listed the code (see below) which when compiled with

rootcint -f RecoDataK2Cint.cc -c -I$BFROOT/package/root/5.10-00f/Linux26SL4_i386_gcc346/include RecoGMatchK.hh RecoDataK2_LinkDef.hh

g++ -g -O -D__STD_ALGORITHM -Wall -Wno-sign-compare -Wno-parentheses -fpermissive -I$BFROOT/package/root/5.10-00f/Linux26SL4_i386_gcc346/include -c RecoDataK2Cint.cc -o RecoDataK2Cint.o

shows the error. Removing the optimization flag resolves the error.

I was wondering if there was another workaround or if this is a gcc bug.

Thanks !

Asoka

RecoGMatchK.hh:

//      -*- Mode: c++ -*-

#ifndef RecoGMatchK_HH
#define RecoGMatchK_HH

#include "TObject.h"

class SvtRootClusterI : public TObject {
public:
  SvtRootClusterI() : TObject() {;}
  virtual ~SvtRootClusterI( ) {;}
private:
  ClassDef(SvtRootClusterI,1);         
};
ClassImp(SvtRootClusterI);

template <class RObj_I>
class RecoGMatchK : public TObject {
public:
  RecoGMatchK()  : TObject() {;}
  virtual ~RecoGMatchK( ) {;}
private:
  ClassDefT(RecoGMatchK,1);         
};

class KanClonesObj2 : public TObject {
public:
  KanClonesObj2(const char* className) : TObject(){;}
  KanClonesObj2() : TObject(){;}
  virtual ~KanClonesObj2() {;}
private:
  ClassDef(KanClonesObj2,1);
};

template <class RObj_I>
class RecoSimpleGMatchListK :
  public KanClonesObj2 {
public:
  RecoSimpleGMatchListK()
    :KanClonesObj2 ( RecoGMatchK< RObj_I >::Class_Name()) {;}
  virtual ~RecoSimpleGMatchListK() {;}
private:
  ClassDefT(RecoSimpleGMatchListK,1);
};

class RecoSimpleSvtGMatchListK : public RecoSimpleGMatchListK<SvtRootClusterI> {
public:
  RecoSimpleSvtGMatchListK()
    :RecoSimpleGMatchListK<SvtRootClusterI>(){;}
  virtual ~RecoSimpleSvtGMatchListK() {;}
private:
  ClassDef(RecoSimpleSvtGMatchListK,1);
};
ClassImp(RecoSimpleSvtGMatchListK);  

RecoSimpleSvtGMatchListK RecoSimpleSvtGMatchList; 

#endif

RecoDataK2_LinkDef.hh:

//      -*- Mode: c++ -*-
#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class RecoGMatchK<SvtRootClusterI>;
#pragma link C++ class KanClonesObj2;
#pragma link C++ class RecoSimpleGMatchListK<SvtRootClusterI>;
#pragma link C++ class RecoSimpleSvtGMatchListK;
#pragma link C++ class SvtRootClusterI;


#endif

Hi Asoka,
this definitely looks like a GCC bug in the lookup. You might want to check whether it was already reported, and if not report it yourself.
Cheers, Axel.