https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122020
Bug ID: 122020
Summary: isnan raises FE_INEXACT
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgcc
Assignee: unassigned at gcc dot gnu.org
Reporter: tydeman at tybor dot com
Target Milestone: ---
I reported this against glibc and they said the bug is in libgcc.
It appears that certain NANs causes isnan() to raise FE_INEXACT.
/* Prereq: dnf install libdfp-devel */
#define __STDC_WANT_DEC_FP__ 1
#define __STDC_WANT_IEC_60559_DFP_EXT__ 1
#include <assert.h>
#include <stdio.h>
#include <limits.h>
#include <errno.h>
#include <fenv.h>
#include <float.h>
#include <math.h>
#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){
_Decimal128 dfp33_128 = DEC_NAN;
long double ld33;
double d33;
float f33;
int flags;
feclearexcept(FE_ALL_EXCEPT);
f33 = d33 = ld33 = dfp33_128;
flags = fetestexcept(FE_ALL_EXCEPT);
assert( 0 == flags );
feclearexcept(FE_ALL_EXCEPT);
assert( isnan(f33) );
assert( isnan(d33) );
assert( isnan(ld33) );
flags = fetestexcept(FE_ALL_EXCEPT);
assert( FE_INEXACT != flags ); /* fails here */
}
return 0;
}