This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/21360] New: wrong result of 'if' statement with comparing of floating point with gcc.
- From: "dtemirbulatov at ru dot mvista dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 May 2005 15:05:35 -0000
- Subject: [Bug c/21360] New: wrong result of 'if' statement with comparing of floating point with gcc.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Following code produces wrong results:
#include <stdio.h>
float f = -1.0f ;
int main( void )
{
if ( (unsigned int)f != (unsigned int)-1.0f ) {
printf( "%-12s %04d:NG...[%u]--->[%u]\n",
__FILE__, __LINE__, (unsigned int)-1.0f, (unsigned int)f ) ;
} else {
printf( "[%u]--->[%u] :OK\n", (unsigned int)-1.0f, (unsigned
int)f ) ;
}
return( 0 ) ;
}
[dinar@dinar tmp]$ /home/dinar/work/gcc-builds/gnu/gcc-i686-pc-linux-gnu/bin/gcc
sample.c -o sample
[dinar@dinar tmp]$ ./sample
sample.c 0010:NG...[0]--->[4294967295]
[dinar@dinar tmp]$ /home/dinar/work/gcc-builds/gnu/gcc-i686-pc-linux-gnu/bin/gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure
--prefix=/home/dinar/work/gcc-builds/gnu/gcc-i686-pc-linux-gnu/
--enable-languages=c,c++
Thread model: posix
gcc version 4.1.0 20050429 (experimental)
--
Summary: wrong result of 'if' statement with comparing of
floating point with gcc.
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dtemirbulatov at ru dot mvista dot com
CC: dtemirbulatov at ru dot mvista dot com,gcc-bugs at gcc
dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21360