jos@ele.tue.nl (Jos van Eijndhoven) (08/07/90)
I just discovered a bug in the apollo 10.2 C compiler on a DN3000, regarding int to double type conversion between two fields in a union. The problem is shown by the following tiny program: /****** show cc bug in union type conversion *****/ #include <stdio.h> main() { union { int i; double f; } val; double f; val.i = 1; f = (double)(val.i); val.f = (double)(val.i); printf("f = %g, val.f = %g\n", f, val.f); } /**************************************************/ The program will print two different values!!! Changing the order of int and double in the union doesn't help. Changing the union to a struct removes the error. I am severely hindered by this bug in a larger program. Is this problem known already, and if so is there a patch available? Does anybody know an easy way to circumvent the problem? Any help appreciated, Jos van Eijndhoven Eindhoven University of Technology The Netherlands jos@es.ele.tue.nl
rehrauer@apollo.HP.COM (Steve Rehrauer) (08/08/90)
In article <538@al.ele.tue.nl> jos@ele.tue.nl (Jos van Eijndhoven) writes: >I just discovered a bug in the apollo 10.2 C compiler on a DN3000, >regarding int to double type conversion between two fields in a union. >The problem is shown by the following tiny program: > >/****** show cc bug in union type conversion *****/ >#include <stdio.h> >main() >{ union > { int i; > double f; > } val; > double f; > > val.i = 1; > > f = (double)(val.i); > val.f = (double)(val.i); > printf("f = %g, val.f = %g\n", f, val.f); >} >/**************************************************/ > >The program will print two different values!!! >Changing the order of int and double in the union doesn't help. >Changing the union to a struct removes the error. > >I am severely hindered by this bug in a larger program. >Is this problem known already, and if so is there a patch available? >Does anybody know an easy way to circumvent the problem? Jos, I've verified that the bug exists in 6.7 C, and that it is fixed in 6.8. The 6.8 C compiler belongs to what we're internally calling the "CR1.0" compiler release, and is currently in Beta test. Gee, it'd be nice if you volunteered to be a CR1.0 Beta site! :-) However, more realistically, there is also a patched 6.7 C that fixes this problem. Ask your friendly neighborhood customer-service rep for the latest 6.7 C compiler, referred to internally as "1989.1 plus". >Any help appreciated, You're welcome. -- >>"Aaiiyeeee! Death from above!"<< | (Steve) rehrauer@apollo.hp.com "Spontaneous human combustion - what luck!"| Apollo Computer (Hewlett-Packard)