Reference bug!

Hi!
I have below code:

class AClass
{
public:
double dtest[200];
AClass()
{
memset(dtest, 0, 200*sizeof(double));
};

void Judge()
{
double& d = dtest[0];
printf("%4.2f", dtest[0]);
printf("%4.2f", d); // Occur error here
printf(“Finish Judge”);

return false;

};

void Accord()
{
return Judge();
};
};

class BClass
{
public:
void Run()
{
AClass A;
for (int i=0; i<50; i++)
{
for (int j = 0; j <= 200; j++)
{
A.Accord();
}
}
}
};

int main()
{
BClass B;
B.Run();

printf(“Finish!”);
return 0;
};

//////////////////////////////////////

occur error in pcode.c
/*******************************************************

  • G__LD_Rp0_double()
    *******************************************************/
    void G__LD_Rp0_double(pbuf,psp,offset,var,ig15)
    G__value *pbuf;
    int *psp;
    long offset;
    struct G__var_array *var;
    long ig15;
    {
    G__value *buf= &pbuf[(*psp)++];
    buf->tagnum = -1;
    buf->type = ‘d’;
    buf->typenum = var->p_typetable[ig15];
    buf->ref = (long)(var->p[ig15]+offset);
    buf->obj.d = (double)buf->ref; //Occur error here,buf->ref = 0
    }

My platform is vc++.net 2003 and windows xp

I’ve downloaded the newest version(“5.15.159, Nov 14 2004”), and try above code, It still occur error!

CINT’s version of printf has limited support due to the difficulties of implementing support for variable number of parameters in a portable way.

As a workaround, either compile your code (using ACLiC) for example or use iostream (cout << d << endl; ) instead of printf.

Cheers,
Philippe.

It’s not the limitation of printf func. I used printf only to display the bug!

I’ve upgrae cint to v5.15.162, but above bug still exists.

It’s not the limitation of printf, u can replace the line “printf(”%d", d)" like “int dd = d;”, cint still occurs error!