This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/48236] uint64_t and int64_t behave differently when converting to float
- From: "juanval at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 22 Mar 2011 14:08:30 +0000
- Subject: [Bug c/48236] uint64_t and int64_t behave differently when converting to float
- Auto-submitted: auto-generated
- References: <bug-48236-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48236
Jon Valdes <juanval at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |juanval at gmail dot com
--- Comment #1 from Jon Valdes <juanval at gmail dot com> 2011-03-22 14:08:27 UTC ---
Even simpler code. uint64_t and int64_t converted to floats differ beginning at
16 million.
Fails at value 16777217:
----------------------->8-----------------------
#include <stdint.h>
#include <stdio.h>
int main()
{
uint64_t ui ;
int64_t i ;
for( i=0, ui=0 ; ; i++ , ui++ )
if( (float) i != (float) ui )
{
printf("error: ui=%lld\n" , ui ) ;
break ;
}
return 0 ;
}
-----------------------8<-----------------------
Fails on default params, -O0, -O3...