(no subject)

From: Federico Carminati (Federico.Carminati@cern.ch)
Date: Tue Jul 21 1998 - 18:46:44 MEST


Dear RooTers,
  me and Marek Kowalsky found this interesting example:

void Check(Float_t *p[]);
void test8()
{
  //
  // test for the array of pointers
  //

Float_t *p[2];
p[0] = new Float_t[2];
p[1] = new Float_t[2];

*p[0] = 1;
printf("p01 = %d  %f\n",p[0],*p[0]);
p[0]++;
*p[0] = 2;
printf("p02 = %d  %f\n",p[0],*p[0]);

Check(p);
}
void Check(Float_t *p[])
{
printf("p02 = %d  %f\n",p[0],*p[0]);
p[0]--;
printf("p01 = %d  %f\n",p[0],*p[0]);
//
//  So far so good...
//
 (*p[0]) = 7;
 printf("p01 = %d  %f\n",p[0],*p[0]); // and here it crushes!!

}

This works as expected. But if you remove the brackets around *p[0] used
as an lvalue, is p[0] which is assigned the value of 7, and the next line
bombs. Note that *p[0] works well as a left value few lines above in the
main program, but NOT in the procedure check. Any hint? Thanks,



                                            Federico Carminati


==============================================================================
||                                                                          ||
||                _/_/_/_/_/_/_/        _/_/_/_/           _/               ||
||               _/                   _/      _/         _/ _/              ||
||              _/                  _/                 _/   _/              ||
||             _/_/_/_/_/_/       _/                 _/     _/              ||
||            _/                 _/                _/       _/              ||
||           _/                 _/               _/ _/_/_/_/_/              ||
||          _/                  _/       _/    _/           _/              ||
||         _/                    _/_/_/_/    _/             _/              ||
||                                                                          ||
==============================================================================
|| Federico Carminati             ||  Tel.: +41.22.767.4959                 ||
|| CERN-EP                        ||  Fax.: +41.22.767.9075                 ||
|| 1211 Geneva 23                 ||                                        ||
|| Switzerland                    ||                                        ||
==============================================================================



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:35 MET