Hello Rene, Thank you for forwarding me this information. I overlooked this bug report. I fix this in cint5.14.66. Because I read the message after I copied 5.14.65, the fix is not included in the latest copy. You can make a change to your local version as follows. In src/func.c, around line 640, please add lines enclosed by G__OLDIMPLEMENTATION1449 Thank you Masaharu Goto #ifdef G__ASM if(G__asm_noverflow) { #ifndef G__OLDIMPLEMENTATION1449 #ifdef G__ASM_DBG if(G__asm_dbg) fprintf(G__serr,"%3x: PUSHSTROS\n",G__asm_cp); #endif G__asm_inst[G__asm_cp] = G__PUSHSTROS; G__inc_cp_asm(1,0); #endif /* 1449 */ #ifdef G__ASM_DBG if(G__asm_dbg) fprintf(G__serr,"%3x: SETSTROS\n",G__asm_cp); #endif G__asm_inst[G__asm_cp] = G__SETSTROS; G__inc_cp_asm(1,0); } #endif /* call operator[] */ >---------- Forwarded message ---------- >Date: Sun, 26 Nov 2000 18:39:54 +0100 (MET) >From: Denis NOUAIS <nouais@to.infn.it> >To: Andre Holzner <Andre.Holzner@cern.ch> >Cc: roottalk@pcroot.cern.ch >Subject: Re: [ROOT] TArrayD in Classes > > >Hi Andre, > >I tried your example on version 2.25.02 and i got an error message at >event 1: > >filling in 20 events > Event 0 > Event 1 >Error in <TArrayD::operator[]>: index 1 out of bounds (size: 0, this: >0x4027c418) > >I don't understand why, but eliminating the paranthesis in the line > (*mass_values)[i] = 0; > => *mass_values[i] = 0; >it works. S.b can explain the reason please? > >I have a related question about TArrays: >In this example, I'd declare TArrayD instead of TArrayD* as follows >in order to simplify. Is it a bad idea? > > >class ClDrawer >{ >public: > ClDrawer(); >private: > int num_events; // number of selected events > TArrayD mass_values; // mass points >}; > >ClDrawer::ClDrawer() >{ > num_events = 20; > mass_values.Set(num_events); > printf("filling in %d events\n",num_events); > int i; > for (i=0; i<num_events; ++i) > { > printf(" Event %d\n",i); > mass_values[i] = 0; > } > printf("done filling\n"); >} > > >Cheers > >Denis > >------------------------------------------------------------------------ > Istituto Nazionale di Fisica Nucleare | Office: A 39 > Via Pietro Giuria, 1 | Phone: (+39)011-6707377/7359 > I-10125 TORINO (Italy) | Fax: (+39)011-6699579 >------------------------------------------------------------------------ > at Cern: office 160-R-030, phone (+41)22-7672917/72918 >------------------------------------------------------------------------ > > > >On Sun, 26 Nov 2000, Andre Holzner wrote: > >> Hello, >> >> maybe this is a trivial question. I'm using root 2.26/00 of 7 November >> 2000 >> on Linux. >> >> I have a file ClDrawer.C: >> >> #include <TArrayD.h> >> >> class ClDrawer >> { >> public: >> ClDrawer(); >> >> int num_events; // number of selected events >> >> TArrayD *mass_values; // mass points >> >> >> }; >> >> //---------------------------------------------------------------------- >> >> ClDrawer::ClDrawer() >> { >> num_events = 20; >> >> mass_values = new TArrayD(num_events); >> mass_values->Set(num_events); >> >> printf("filling in %d events\n",num_events); >> >> int i; >> for (i=0; i<num_events; ++i) >> { >> printf(" Event %d\n",i); >> (*mass_values)[i] = 0; >> } >> >> printf("done filling\n"); >> } >> >> >> After starting root, I run >> >> root [0] .L ClDrawer.C >> root [1] ClDrawer *cldrawer = new ClDrawer; >> filling in 20 events >> Event 0 >> Event 1 >> done filling >> root [2] >> >> i.e. the loop stops after the second event instead of filling in all 20. >> >> If I comment out the line >> (*mass_values)[i] = 0; >> >> >> I get the output up to Event 19. >> >> >> What am I doing wrong ? >> >> >> >> thanks, >> >> >> Andre >> >> >> -- >> ------------------+---------------------------------- >> Andre Holzner | +41 22 76 76750 >> Bureau 32 2-C13 | Building 32 >> CERN | Office 2-C13 >> CH-1211 Geneve 23 | http://wwweth.cern.ch/~holzner/ >> >
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:38 MET