AIX 1.1 C compiler bug?

Anthony M. Richardson amr at dukee.egr.duke.edu
Mon Mar 5 09:56:54 AEST 1990


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 at dukee.egr.duke.edu

take the address of 



More information about the Comp.unix.aix mailing list