[ROOT] RE:new handling of operator new

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Fri Jan 05 2001 - 08:17:38 MET


Dear Richy,

I am very glad that you ask those questions.

>This weekend I learned about the new scheme for handling a global
>overloaded operator new in Cint.  Specifying -M0x110 instead of -M0x10
>fixes a couple of errors for GiNaC-Cint, because we are including an 
>external header file which defines a two-argument operator new.  It seems
>to work fine so far, even without changing the definition of opeator new
>to account for G__getgvp().  It wouldn't be easy to do so anyways because
>those headers are *very* public and changing them is unfortunately
>completely out of question.
>
>My two questions are:
>* Why don't we run into trouble?  Is it because we aren't calling that
>  operator new from Cint?

I think the simplest answer is because it is designed like that.
In theory, Cint dictinoary should not call your version of operator
new/delete anyway.  So, you do not need to change your source. 

In the old scheme, cint dictionary had one or two of following 
functions.
    static void* operator new(size_t);
    static void* operator new(size_t,void*);
    static void operator delete(void*);

This scheme had a problem because   not all compilers allow operator
new/delete to be 'static'.  Above functions are
really fundamental to C++ memory allocation system. Failing to declare
those functions 'static' causes severe problem.

In the new scheme, cint dictionary has following functions instead.
    void* operator new(size_t,[DLLID]_t*);
    static void G__operator_delete(void*);
Those functions are known only within the cint dictionary. Hence
there is no risk like the old scheme.

In nether case, cint dictionary does not call your version of 
operator new/delete.


>* How "experimental" is this new scheme exactly?  Currently, we are
>  relying on this functionality to work.

ROOT system switched to the new scheme about a month ago. CERN people
tried this on all possible operating systems. Only IBM AIX xlC had a 
problem and we identified this was a problem of the compiler. 
So, after cint5.14.64, I declare this to be an official implementation.


>It is really hard to understand what's all this about from doc/*.  If this
>is disussed elsewhere (maybe on roottalk?), could you please provide us a
>pointer?

I am sorry about my poor documentation.  I thought this was an internal
implementation issue that user did not need to know.  The new scheme
separates cint and user code better.

There are several postings in roottalk. Please search
with keyword 'operator new' or 'operator new/delete'. 
If you can not find anything, I'll write another text.

Thank you
Masaharu Goto



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:33 MET