Possible bug in floating point comparison

K S Sreeram sreeram@tachyontech.net
Mon Dec 22 14:37:00 GMT 2003


Hi

The following function goes into an infinite loop for some cases!!!.

void func( double a, double b, double c ) {
	while ( a < (b+c) ) {
		a = b+c;
	}
}

I've attached a test program which has one sample input set which makes
the above function go into an infinite loop

I've tested with following versions of gcc:
 Redhat 9.0 (gcc 3.2.2), cygwin(2.95) and cygwin(3.3.1).
In all the cases i used only the default gcc options "gcc <filename>".

I've also tested with MSVC and it doesnt fail at all. From initial
investigation it seems that the 'fcompp' instruction used by gcc does
not work as expected in some cases.

Regards
Sreeram
Tachyon Technologies



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cupgcc.c
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20031222/ee2109ce/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 250 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20031222/ee2109ce/attachment.sig>


More information about the Gcc mailing list