Hi rooters,
First, thanx again to René, Masaharu Goto and others who answered to my
past questions.
But, of course, I have another one:
The following code compile and run as expected under g++ (changing
'bug101' to 'main') but unexpectingly crash under ROOT/CINT:
<<<< File bug101.C
class A
{
public:
A(void) {
fA= new int*[2];
fA [0]=0xA1A1;
fA [1]=0x1515;}
~A(void){delete fA;}
int **Get(void) {return fA;}
private:
int **fA;
};
void bug101(void)
{
for (int i=0;i<2;i++)
{
A a;
int **t=a.Get();
cout <<t<<" "<<t[0]<<" "<<t[1]<<endl;
}
}
>>>>
(Of course dont expect the class A to have any purpose ;)
Output of gcc (complaining about some int to pointer trick at
compilation, but we understand why):
0x8049c98 0xa1a1 0x1515
0x8049c98 0xa1a1 0x1515
ROOT version 3.00.06:
root [0] .x bug101.C
0x87c7040 0xa1a1 0x1515
0x87c7040 0xa1a1 0x1515
ROOT version 3.01.05:
root [0] .x bug101.C
0x87f7fe8 0xa1a1 0x1515
0xa1a1
*** Break *** segmentation violation
Root > Function bug101() busy flag cleared
The wrong pointer is returned (fA[0] instead of fA).
The problem seems to arise from the creation of the object in the 'for'
loop.
Thanx for your attention.
Yannick
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:49 MET