Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!rpi!rpi.edu!rodney From: rodney@dali.ipl.rpi.edu (Rodney Peck II) Newsgroups: gnu.g++ Subject: argument mixup -- register name typo? Message-ID: Date: 1 Dec 89 02:20:46 GMT Distribution: gnu Organization: Rensselaer Polytechnic Institute Image Processing Lab, Troy NY Lines: 78 Help! I think I unwittingly found a program (maybe a typo?) in the argument passing in g++. Here's what happens...(I've got a conditional bkpt to catch the problem here) Starting program: /home/rodney/courses/paradigm/bank/main Bpt 1, enqueue_PSbqueue_PScitizen ($this=(struct bqueue *) 0x140ac, patron=(struct citizen *) 0x14) (bqueue.cc line 76) (gdb) up Reading in symbols for citizen.cc...done. #1 0x2788 in enter_bank_PScitizen ($this=(struct citizen *) 0x15ed8) (citizen.cc line 71) (gdb) print this $1 = (struct citizen *) 0x15ed8 (gdb) down #0 enqueue_PSbqueue_PScitizen ($this=(struct bqueue *) 0x140ac, patron=(struct citizen *) 0x14) (bqueue.cc line 76) (gdb) print patron $2 = (struct citizen *) 0x14 (gdb) print $i1 $3 = 89816 (gdb) print/x $i1 $4 = 0x00015ed8 (gdb) print/x $l1 $5 = 0x00000014 (gdb) --- portion of program... bqueue.cc which is the code for bqueue::enqueue void bqueue::enqueue(citizen *patron) { =>if (head == 0) tail = 0; for(node *P=tail;1;P=P->prev) { if ((P==0) || !condition((void *)patron,(void *)P->info)) break; } insert_before(P,new node(patron)); tickle_queue(); } The breakpoint is where the arrow is pointing above. void citizen::enter_bank() { if (type <= KNIGHT) schedule_entrance(); // get in line entrance_time = Events.time; // set the time this one came in to now // now, get in line. The queue will alert the teller that I'm here =>entrance.enqueue(this); } The part of citizen.cc which calls bqueue::enqueue. Again, the arrow points to the part in question. As you can see from the prints and backtraces, when in enter_bank, `this' has a proper value and should be passed to entrance.enqueue properly. In enqueue, however, it actually gets a 0x14. This corresponds to register $i1 but register $l1 has the actual value that should have been passed. In fact, if I put a conditional breakpoint in there and have it assign $l1 to $i1 and continue, everything works fine. Oddly, this problem doesn't always appear. Sometimes, to make things worse, the program executes perfectly, but not often. HELP!!! Here's the version info: dali.ipl.rpi.edu% g++ -v g++ version 1.35.1- dali.ipl.rpi.edu% gcc -v gcc version 1.36 dali.ipl.rpi.edu% Please reply quickly if you have any idea what is happening, this project is due tomorrow! -- Rodney Brought to you by Super Global Mega Corp .com