Skip to content

complex divide: zero / infinity raises FE_INVALID #162837

@tydeman

Description

@tydeman

This fails:

#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 fc29;
    int flags;
    errno = 0;
    feclearexcept(FE_ALL_EXCEPT);
    fc29 = 0.f / CMPLXF(0.f,INFINITY); /* 0 / infinity */
    flags = fetestexcept(FE_ALL_EXCEPT);
    assert( 0 == errno );
    assert( 0.f == crealf(fc29) );
    assert( 0.f == cimagf(fc29) );
    assert( !(FE_INVALID & flags) );	/* fails here */
  }
  return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"floating-pointFloating-point math

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions