https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122082
Bug ID: 122082
Summary: complex multiply: w * conj(w) should have zero
imaginary part
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: ---
Intel x86_64, sse FPU, Fedora Linux
#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 fc26;
int flags;
errno = 0;
feclearexcept(FE_ALL_EXCEPT);
fc26 = CMPLXF(FLT_MAX,1.1F) * CMPLXF(FLT_MAX,-1.1F); /* w * conj(w) */
flags = fetestexcept(FE_ALL_EXCEPT);
assert( 0 == errno );
assert( FE_OVERFLOW|FE_INEXACT == flags );
assert( INFINITY == crealf(fc26) );
assert( 0.f == cimagf(fc26) ); /* fails here with NAN */
}
return 0;
}