TString and fstream problems on SLC3

Given this program (test.C):

#include
#include
#include <TString.h>
using namespace std;

int main(){
ofstream ftxt(“my_output_file”);
return 1;
}

and compiling ON SLC3 with:

“g++ -c -I$ROOTSYS/include -finline-functions test.C”

gives compilation errors. Just dropping the TString include statement solves the problem. Is this a feature or a bug? The problem does not show up in CERN Redhat7.3 versions for instance. Needless to say that we need to switch on inline-functions and use ROOT at the same time.

Here it is the exact error report:
/usr/include/c++/3.2.3/bits/fstream.tcc: In member function _Traits::pos_type std::basic_filebuf<_CharT, _Traits>::seekoff(_Traits::off_type, std::_Ios_Seekdir, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]': /usr/include/c++/3.2.3/bits/fstream.tcc:95: instantiated fromstd::basic_filebuf<_CharT, _Traits>* std::basic_filebuf<_CharT, _Traits>::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits]’
/usr/include/c++/3.2.3/fstream:466: instantiated from void std::basic_ofstream<_CharT, _Traits>::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]' /usr/include/c++/3.2.3/fstream:432: instantiated fromstd::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits]‘
hula.C:7: instantiated from here
/usr/include/c++/3.2.3/bits/fstream.tcc:454: ambiguous overload for `
std::streampos& + char* const&’ operator
/usr/include/c++/3.2.3/bits/fstream.tcc:454: candidates are: operator+(int,
char*)
/usr/include/c++/3.2.3/bits/fpos.h:87: std::fpos<_StateT>
std::fpos<_StateT>::operator+(long int) [with _StateT = mbstate_t]
/afs/cern.ch/exp/ams/Offline/root/Linux/pro/include/TString.h:177:
TString operator+(long unsigned int, const TString&)
/afs/cern.ch/exp/ams/Offline/root/Linux/pro/include/TString.h:176:
TString operator+(long int, const TString&)
/afs/cern.ch/exp/ams/Offline/root/Linux/pro/include/TString.h:175:
TString operator+(char, const TString&)
/afs/cern.ch/exp/ams/Offline/root/Linux/pro/include/TString.h:171:
TString operator+(const char*, const TString&)

                                                  *** Juan ***

Are you sure that the error is generated by your test.C program (I am wondering because your error message mentioned both a hula.C file and the operator+ neither of which are in you example)?

Philippe.

[quote=“pcanal”]Are you sure that the error is generated by your test.C program (I am wondering because your error message mentioned both a hula.C file and the operator+ neither of which are in you example)?

Philippe.[/quote]

Yes. “hula.C” was the former name of the program. (Sorry, I renamed it for the e-mail but I quoted the previous output by mistake).
So whenever you see “hula.C”, translate it as “test.C”.

What we have also seen in that in a SLC3 machine in which we have installed gcc3.3.2 the error disappears. The default SLC3 gcc version is 3.2.3.

So it is maybe related with the gcc implementation of SLC3, but there is no doubt that there is a “destructive” interference with ROOT.

Hi,

This is an ineffeciency in gcc 3.2.3 which apparently has been improved since.

To work around the problem add the line:char* operator+( std::streampos&, char* );after the #include statements.

Cheers,
Philippe.