Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!usc!ucsd!helios.ee.lbl.gov!brutus.cs.uiuc.edu!stan From: stan@csam.lbl.gov (See-Mong Tan) Newsgroups: comp.lang.c++ Subject: Bug in 2.0 with Pass by Reference? Keywords: bug, cfront 2.0, pass by reference Message-ID: <4577@helios.ee.lbl.gov> Date: 7 Jan 90 02:35:49 GMT Sender: usenet@helios.ee.lbl.gov Reply-To: stan@brutus.cs.uiuc.edu (See-Mong Tan) Followup-To: comp.lang.c++ Organization: Lawrence Berkeley Laboratory, University of Illinois Lines: 48 X-Local-Date: 6 Jan 90 18:35:49 PST I seem to have stumbled upon a bug with cfront 2.0. It has to do with passing a variable by reference. It failed in this code here: There are two functions, the first is: > int FSI::pathOpen( char *, StoredObject * &, Class *); Note that it expects the second argument to be a variable that's passed by reference. The next function calls the first: > int FSI::keys(char *dirname, char *buf, int size, int &count) > { > ObjectDictionary * od = 0; > // call pathOpen, pass variable od by reference > int status = pathOpen( dirname, od, ObjectDictionaryClass ); > .... > } The generated code for the second function however, looks like: > int keys__ [... declarations ..] > { > > struct ObjectDictionary *__1od; > int __1status; > > { > struct StoredObject *__0__I36; // A temporary variable? > > __1status = pathOpen__3FSIFPcRP12StoredObjectP5Class ( __0this, __0dirname, (struct StoredObject **) ( (__0__I36 = (struct StoredObject *) __1od ), (& __0__I36 )) , ObjectDictionaryClass); > > ... > } > > } Notice that the call to pathOpen does not correctly pass by reference the second argument... why does this happen? It happened on a Cray first, with the cfront I ported, so I thought I broke something, but then cfront 2.0 for the Suns here gave the same output. Is there a fix for this? stan