Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site noao.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!hao!noao!rwolff From: rwolff@noao.UUCP (Richard Wolff) Newsgroups: net.unix-wizards,net.lang.c,net.bugs.4bsd Subject: Comparison failure in C compiler Message-ID: <438@aquila.noao.UUCP> Date: Wed, 28-Nov-84 11:07:04 EST Article-I.D.: aquila.438 Posted: Wed Nov 28 11:07:04 1984 Date-Received: Fri, 30-Nov-84 07:13:27 EST Distribution: net Organization: Natl. Optical Astronomy Observatories, Tucson, AZ USA Lines: 37 Xref: godot net.unix-wizards:3870 net.lang.c:2036 net.bugs.4bsd:618 The following program (sadly) prints the message main() { int n, i; float x[2]; x[0] = 1.; n = 10000; i = 0; if(x[i] > n) printf("finds %g is > %d\n",x[i],n); } The relevant assembly code that implements the comparison is movl -8(fp),r0 cvtld -4(fp),r2 cvtfd -16(fp)[r0],r1 cmpd r1,r2 The selection of "r1" is unfortunate. The section of pcc/table.c that seems to be at fault is OPLOG, FORCC, SAREG|AWD, TFLOAT, SAREG|AWD, TDOUBLE, 2*NAREG, RESCC, " cvtfd AL,A1\n cmpd A1,AR\nZP", Changing A1 to A2 solves the problem. But, is this a correct solution, and is it the best one? -- Richard Wolff, National Optical Astronomy Observatories, Tucson, AZ Usenet: {allegra,arizona,astrovax,decvax,hao,ihnp4} !noao!rwolff Arpa: noao!rwolff@lbl-csam