[Bug c/67570] New: comparison rules fails
ka_bena at yahoo dot fr
gcc-bugzilla@gcc.gnu.org
Mon Sep 14 09:45:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67570
Bug ID: 67570
Summary: comparison rules fails
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: ka_bena at yahoo dot fr
Target Milestone: ---
#include <stdio.h>
int main(void)
{
int pos ;
int pos1 ;
int pos2 ;
long double A = 0.L ;
union {
long double X ;
char unsigned mask[sizeof(A)] ;
} alfa ;
alfa.X = A ;
pos = 32 ;
pos1 = 11 - ( pos - 1 ) / 8 ;
pos2 = 8 ;
alfa.mask[pos1] =((char unsigned )1 << (sizeof(char unsigned) * 8 - pos2)) ^
alfa.mask[pos1] ;
printf ( " [alfa.X] = %LE \n" , alfa.X ) ;
printf ( " [alfa.X == 0.L] = %i \n" , alfa.X == 0.L ) ;
printf ( " [alfa.X != 0.L] = %i \n" , alfa.X != 0.L ) ;
printf ( " [alfa.X <= 0.L] = %i \n" , alfa.X <= 0.L ) ;
printf ( " [alfa.X >= 0.L] = %i \n" , alfa.X >= 0.L ) ;
printf ( " [alfa.X < 0.L] = %i \n" , alfa.X < 0.L ) ;
printf ( " [alfa.X > 0.L] = %i \n" , alfa.X > 0.L ) ;
return 0 ;
}
/*
Results:
[alfa.X] = 0.000000E+000
[alfa.X == 0.L] = 0
[alfa.X != 0.L] = 1
[alfa.X <= 0.L] = 0
[alfa.X >= 0.L] = 0
[alfa.X < 0.L] = 0
[alfa.X > 0.L] = 0
Note:
Binary representation IEEE 754 of alfa.X is:
0000000000000000 0 000000000000001
0000000000000000000000000000000000000000000000000000000000000000
It seems that comparison rules fails in this case.
Microsoft Windows XP Profesional version2002 Service Pack 3.
Gcc 4.8.0 win32 mingw32 -std=C99
*/
More information about the Gcc-bugs
mailing list