Skip to content

Initialization of union not raise expected FPU flag #166866

@tydeman

Description

@tydeman
#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){
  feclearexcept(FE_ALL_EXCEPT);
  errno = 0;
  if(1){
    union { float f32; int i; } uf0 = { 0.F / 0.F };
    int flags;
    flags = fetestexcept(FE_ALL_EXCEPT);
    assert( 0 == errno );
    assert( isnan( uf0.f32 ) );
    assert( 0 != flags );	/* fails here */
    assert( FE_INVALID == flags );
  }
  return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.floating-pointFloating-point math

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions