Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!bionet!ames!haven!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Compiler bug or gray area in C? Message-ID: <28081@mimsy.umd.edu> Date: 29 Nov 90 08:46:17 GMT References: <1990Nov28.220233.2630@ingres.Ingres.COM> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 61 In article <1990Nov28.220233.2630@ingres.Ingres.COM> daveb@ingres.com writes: >Given this simplification: > > extern double D, foo(); > > foo( i ) > int i; > { Type error, foo returns double and int. Because of the next problem, I am almost sure you meant `bar(i)': > double x; > int changes = 0; > do { > > x = foo( i ); Infinite recursion: to compute foo(i) we must first compute foo(i) before doing anything else. > if( x < D ) > { > changed++; > D = x; > } > > } while( !changed ); > } Repaired example: fn() { double x, eval(void); extern double D; extern void nop(void); for (D = x = eval();;) { nop(); /* does not change D */ if (x < D) D = x; else break; } } >is it reasonable for this to not terminate? I think so; I think that the reason you give here is not (quite) outlawed. >We see a number of compilers that keep x in a register with extended >precision, so that it has bits that are not in the global D. Thus, the >comparison (x < D) fails, even after D is assigned the value of x. > >Yes, floating point in C is peculiar, but is it _this_ peculiar? (Floating point in C is no more peculiar than floating point anywhere else. Or, more succinctly, floating point is peculiar everwhere.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris