RE: [ROOT] bug concerning interpreted exceptions

From: James Peachey (peachey@bigband.gsfc.nasa.gov)
Date: Thu Feb 13 2003 - 11:37:17 MET


Hi Valeri,

Surely this could be resolved by an #ifdef to the effect of:

#ifdef using Sun WS compilers
#define EXCEPTION std::exception
#else
#define EXCEPTION exception
#endif

Then both in Api.cxx and in code generated by rootcint
one could use EXCEPTION and have it work correctly
under all circumstances on Sun and HP (and everything else,
presumably.)

James

On Tue, 4 Feb 2003, Faine, Valeri wrote:

> It seems to me this will not work for HP-UX.
> Sorry, I can not check immediately. I have no HP around.
>                       Cheers, Valeri
> 
> 
> > -----Original Message-----
> > From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]
> > On Behalf Of James Peachey
> > Sent: Tuesday, February 04, 2003 12:43 PM
> > To: roottalk@pcroot.cern.ch
> > Subject: [ROOT] bug concerning interpreted exceptions
> > 
> > Hi,
> > 
> > Building root 3.04.02 on Solaris 2.8 with WS 6.0 compiler I have
> > the following problem if I add the flags -DG__EXCEPTION and
> > -DG__STD_EXCEPTION in order to catch compiled exceptions in
> > the interpreter:
> > 
> > CC -O -KPIC -DG__REGEXP1 -DG__UNIX -DG__OSFDLL -Iinclude
> -DG__EXCEPTION -
> > DG__ST
> > D_EXCEPTION -DG__SHAREDLIB -DG__ROOT -DG__REDIRECTIO -
> > ptr/data/anu/isdc/root-3.0
> > 4.02/src/spud/sparc-sun-solaris2.8  -o cint/src/Api.o -c
> cint/src/Api.cxx
> > "cint/src/Api.cxx", line 338: Error: The name exception is ambiguous,
> > exception
> > and std::exception.
> > 1 Error(s) detected.
> > make[2]: *** [cint/src/Api.o] Error 1
> > 
> > The problem is that in /usr/include/math.h on Solaris (which
> > gets #included somehow) there is a C structure with the
> > unfortunate name of exception, which is completely unrelated
> > to C++'s std::exception. Thus, even though in Api.cxx there
> > is a "using std::exception;" statement, the ambiguity
> > described above still occurs.
> > 
> > I find that if I fully qualify the typename exception in
> > cint/src/Api.cxx:338:
> > 
> >   catch(std::exception& x) {
> > 
> > ...the problem goes away, and I am able to build Root.
> > 
> > However, in my code the problem comes back when I attempt
> > to derive a class from std::exception and make a dictionary
> > for it. Code generated by rootcint frequently (always?)
> > #includes math.h, and also uses the unqualified name exception,
> > resulting in the same ambiguity.
> > 
> > Although I am hitting this particular problem due to a poor
> > choice made by a proprietary OS, this seems to me like a more
> > general problem. Specifically, it would be more robust for all
> > code generated by Cint to qualify fully all typenames from
> > namespace std. Does this seem like a reasonable and/or feasible
> > thing to do?
> > 
> > Regards,
> > James
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET