Passing floats - Is this a bug?

Frank J. Henigman fjhenigman at watcgl.waterloo.edu
Fri Oct 6 06:41:51 AEST 1989


Take a look at the following program.

------------------------------------------------------------------
bar(x)
  float *x;
  {
  printf("bar:  %f\n", *x);
  }

foo(x)
  float x;
  {
  printf("foo:  %f\n", x);
  bar(&x);
  }

main()
  {
  float x = 1.0;
  foo(x);
  }
------------------------------------------------------------------

Here is the output of this program compiled and run on a 4D/120GTX with 3.1G

foo:  1.000000
bar:  1.875000

You get the same thing EVEN IF COMPILED WITH -float.


Compile it with gcc and you get:

foo:  1.000000
bar:  1.000000

--
fjhenigman at watcgl.uwaterloo.ca                       Computer Graphics Lab
fjhenigman at watcgl.waterloo.edu   Frank J. Henigman   University of Waterloo
 ...!watmath!watcgl!fjhenigman                       Waterloo, Ontario, Canada
-- 
fjhenigman at watcgl.uwaterloo.ca                       Computer Graphics Lab
fjhenigman at watcgl.waterloo.edu   Frank J. Henigman   University of Waterloo
 ...!watmath!watcgl!fjhenigman                       Waterloo, Ontario, Canada



More information about the Comp.sys.sgi mailing list