https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121873
Bug ID: 121873
Summary: conversion of hex fp wrong
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: tydeman at tybor dot com
Target Milestone: ---
This fails:
#include <assert.h>
#include <limits.h>
#include <errno.h>
#include <stdio.h>
#include <float.h>
#include <fenv.h>
#include <math.h> /* glibc 2.41-11 */
#pragma STDC FENV_ACCESS ON
#pragma STDC FP_CONTRACT OFF
#pragma STDC FENV_ROUND FE_TONEAREST
#pragma STDC FENV_DEC_ROUND FE_DEC_TONEAREST
#pragma STDC CX_LIMITED_RANGE OFF
int main(void){
if(1){
double f17 = 0x10000000000000.800FFFFFFFFFFDFF8p0;
assert( 0x10000000000001.p0 == f17 ); /* fails here */
}
return 0;
}
It appears as if the hex fp constant is first converted to 64 bits then to 53
bits,
so suffers double rounding.
This is for Intel x86_64/x87 on Linux Fedora 42.