[comp.unix.aix] AIX 1.1 C compiler bug?

amr@dukee.egr.duke.edu (Anthony M. Richardson) (03/05/90)

The following simple program illustrates what I believe is a bug in the
AIX 1.1 C compiler.

   #include <stdio.h>
   main() { sub1(0.9); }

   int sub1(tick) float tick;
   { sub2(&tick); printf("tick %f\n",tick); }

   int sub2(tick) float *tick;
   { *tick = 0.5; }

The value printed by the printf in routine sub1() is 0.9, not 0.5. The bug
only appears when the address of a function argument is passed to sub2(),
i.e.

   #include <stdio.h>
   main() { float tick=0.9; sub2(&tick); printf("tick %f\n",tick); }

works correctly (prints 0.5).

This is a bug isn't it? (I thought register variables where the only types
you couldn't use the address of operator (&) on.) I can get around it
by using

   int sub1(tick) float tick;
   { float dummy; dummy=tick; sub2(&dummy); tick=dummy; }

but it took me awhile to find the bug in the first place.

Tony Richardson    amr@dukee.egr.duke.edu

take the address of