west@calgary.UUCP (02/23/87)
My brother wrote a very simple program which is bug
free, as far as I can tell.
It does weird things, like not reading floating point
input, and actually printing
%lf
to the screen. This is not possible without double %%'s.
(Unless there is a bug in Lattice). The scanf statement
returns 0 too, so it is fried as well!
code:
#include <stdio.h>
#include <ctype.h>
union stuffing
{
double db;
char c[8];
};
main()
{
union stuffing t;
unsigned char test[80];
int i,again = 1;
while(again){
t.db = 0.0;
printf("input decimal number ");
scanf("%lf",&(t.db)); /* the contents of t is unchanged! */
printf("\n");
printf("%d,%lf\n",0,t.db); /* output of this line tends to be:
0,%lf */
printf("\n");
printf("bytes");
for (i =0;i<=7;i++){
printf("%o ",t.c[i]);
}
printf("\n");
for (i =0;i<=7;i++){
printf("%u ",t.c[i]);
}
printf("\n");
printf("again(y/n)?");
scanf("%s",test);
if (test[0] == 'n') again = 0;
}
}
We applied amfix001 and amfix002 to lc.lib, lcmffp.lib and lc2.
These fixes keep the system from crashing now, but this weird
%lf bug still persists.
Is this a known bug? Is something else wrong that we can fix,
or should Lattice be informed?
Hints and suggestions welcomed (intelligent hints only, please :-) )
Darrin West.
--
Darrin West, Master's Unit (read: student). ..![ubc-vision,ihnp4]!
Department of Computer Science alberta!calgary!west
University of Calgary. Can you say '88 Winter Games?
Brain fault (cortex dumped)