CINT and pointer-to-pointer

From: George Heintzelman (gah@bnl.gov)
Date: Fri Jan 28 2000 - 17:39:30 MET


Hi,

It looks like CINT has trouble understanding pointer-to-pointer types 
for member functions, although the return values appear to work 
correctly if casted right. Raw data members work correctly, though 
typedefs of pointer types cause additional difficulties. An example 
follows:

test_ptop.h
---------------
#ifndef _test_ptop_h_
#define _test_ptop_h_

typedef Int_t *pint;

class X {
public:
  Int_t** a; //!
  pint* b; //!

  Int_t** A() {return a;}
  pint* B() {return b;}

  X(Int_t *&ia , Int_t *&ib ): a(&ia),b(&ib) {}

ClassDef(X,1)
  
};

#endif

---------------
test_ptop.cxx
---------------
#include "Rtypes.h"
#include "test_ptop.h"

ClassImp(X)

---------------
LinkDef.h
---------------
#ifdef __CINT__

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

#pragma link C++ class X;
#pragma link typedef pint;
// #pragma link C++ class Temp<int>-; // works fine
#endif
---------------
Run example: (Linux system, running root 2.23/10)
rcas4008 % g++ -I$ROOTSYS/include -c test_ptop.cxx
rcas4008 % rootcint -f TestCint.cxx -c test_ptop.h LinkDef.h
Note: operator new() masked 1c
Note: operator delete() masked 1c
class X in test_ptop.h line 6 original base of virtual func
rcas4008 % g++ -I$ROOTSYS/include -c TestCint.cxx
rcas4008 % g++ -shared -Wl -o Test.so TestCint.o test_ptop.o
rcas4008 % root
  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   2.23/10  17 December 1999   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

FreeType Engine v1.1 used to render TrueType fonts.

CINT/ROOT C/C++ Interpreter version 5.14.25, Nov 25 1999
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .L Test.so
root [1] Int_t x=5 
root [2] Int_t y=6
root [3] Int_t *px=&x
root [4] Int_t *py=&y
root [5] X obj(px,py)
root [6] obj.A()
(Int_t*)0x85ff4e8               ****** Wrong type. Should be Int_t**.
root [7] *(obj.A())
(Int_t)140493664                ****** Wrong type. Should be Int_t*.
root [8] **((Int_t **)obj.A())
(Int_t)5
root [9] obj.B()
(pint)0x85ff490                  ****** Wrong type. Should be pint *.
root [10] *obj.B()    
(int)140493696                   ****** Wrong type. Should be pint or 
Int_t *
root [11] **((pint *)obj.B())
Error: Illegal pointer operation (tovalue) FILE:/tmp/29991laa_cint 
LINE:1
Error: Illegal pointer operation (tovalue) FILE:/tmp/29991laa_cint 
LINE:1
((unknown))0x85ff490              
*** Interpreter error recovered ***        
root [12] *((pint *)obj.B()) 
Error: Illegal pointer operation (tovalue) FILE:/tmp/29991maa_cint 
LINE:1
((unknown))0x85ff490
*** Interpreter error recovered ***
root [13] obj.a
(Int_t**)0x85ff4e8                  ****** This one works right.
root [14] obj.b
Warning: Unknown type 'unknown' in function argument handled as int 
FILE:iostream.h LINE:521
Internal error: template function call G__ateval failed FILE: LINE:0
(pint*)0x85ff490
*** Interpreter error recovered ***
root [16] **((Int_t **)obj.B())
(Int_t)6                             **** Can only get there by casting 
to
			                  the explicit pointer'd type.



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET