Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!saturn!saturn.ucsc.edu!daniel From: daniel@saturn.ucsc.edu (Daniel Edelson) Newsgroups: comp.lang.c++ Subject: Possible cfront 1.1 bug Keywords: float parameter passing bug Message-ID: <6317@saturn.ucsc.edu> Date: 10 Feb 89 20:14:13 GMT Sender: daniel@saturn.ucsc.edu Reply-To: daniel@saturn.ucsc.edu (Daniel Edelson) Organization: University of California, Santa Cruz; CIS/CE Lines: 42 There appears to be a bug in cfront 1.1 which causes this program to print garbage in the third output. We've found three ways of sidestepping the bug. 1) replace all instances of float with double 2) use a local variable in foo(); pass the address of the local 3) use the oregon C++ compiler =-=-=-=-=-=-=-=-=-= #include void foo(float l); void bar (float *lp); main() { float l=1.5; cout << "main: l == " << l << "\n"; foo(l); } void foo(float l) { cout << "foo: l == " << l << "\n"; bar(&l); } void bar (float *lp) { cout << "bar: *lp == " << *lp << "\n"; } =-=-=-=-=-=-=-=-=-= Rewriting the function foo() like this solves the problem. -=-=-=-=-=-=-=-=-=- foo(float l) { float m=l; cout << "foo: m == " << m << "\n"; bar(&m); } ************************************************************** Daniel Edelson daniel@saturn.ucsc.edu