https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122059
Bug ID: 122059
Summary: complex divide: finite / infinity should be zero
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 on Intel core i5 x86_64 using sse FPU on Fedora Linux 42
#include <assert.h>
#include <limits.h>
#include <errno.h>
#include <stdio.h>
#include <float.h>
#include <fenv.h>
#include <complex.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){
float complex fc25;
int flags;
errno = 0;
feclearexcept(FE_ALL_EXCEPT);
fc25 = CMPLXF(FLT_MAX,FLT_MAX) / CMPLXF(INFINITY,INFINITY) ;
flags = fetestexcept(FE_ALL_EXCEPT);
assert( 0 == errno );
assert( 0.f == cimagf(fc25) );
assert( 0.f == crealf(fc25) ); /* fails here */
assert( 0 == flags );
}
return 0;
}
# flags common to both compiler and linker
export CLFLAGS="\
-fsanitize=undefined \
-fsanitize=address \
-fsanitize=bounds-strict \
-fstack-protector-all"
# flags for compiler
export CFLAGS="-H -std=c23 -O0 -march=native -mhard-float -mfpmath=sse -msse2
-mieee-fp \
-enable-decimal-float=yes \
-fexcess-precision=standard \
-ffp-contract=off \
-fmath-errno \
-fno-associative-math \
-fno-builtin \
-fno-cx-limited-range \
-fno-fast-math \
-fno-finite-math-only \
-fno-reciprocal-math \
-fno-unsafe-math-optimizations \
-frounding-math \
-fsignaling-nans \
-fsigned-zeros \
-ftrapping-math \
${INCS} \
-I/usr/include/dfp"