llvm-project
llvm-project copied to clipboard
static float f = 0.f / 0.f; will not compile
static float f = 0.f / 0.f; will not compile with clang 21.1.7 (and others) on Linux on Intel x86_64
It should be a quiet NaN.
It does seem to compile on both clang trunk: https://godbolt.org/z/P5qdqdfo9 and 21.1.0. Please be more specific.
#include <assert.h>
#include <limits.h>
#include <errno.h>
#include <stdio.h>
#include <float.h>
#include <fenv.h>
#include <complex.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){
static float f27 = 0.f / 0.f;/* cannot compile this constant l-value expression yet */
}
return 0;
}
with command line options:
# flags common to both compiler and linker
export CLFLAGS="-g \
-fsanitize=memory \
-fsanitize=undefined \
-fno-sanitize=float-cast-overflow \
-fno-sanitize=float-divide-by-zero"
# flags for compiler
export CFLAGS="-H -std=c23 -m64 -mfpmath=sse -msse2 -pedantic -O0 \
-fno-fast-math \
-fdenormal-fp-math=ieee \
-fstrict-float-cast-overflow \
-fmath-errno \
-ftrapping-math \
-ffp-contract=on \
-fhonor-infinities \
-fhonor-nans \
-fsigned-zeros \
-fno-associative-math \
-fno-reciprocal-math \
-fno-unsafe-math-optimizations \
-fno-finite-math-only \
-frounding-math \
-ffp-model=strict \
-ffp-exception-behavior=strict \
-Xclang -disable-llvm-optzns ${INCS}"
Fedora Linux 43, Intel i5 x64, clang Fedora 21.1.7-1.fc43
Reproduce: https://godbolt.org/z/3MosvdqWa , std=c23 error it.
How is this different from https://github.com/llvm/llvm-project/issues/161806?
Which is itself a duplicate of #101499