Issue 162830
Summary C23 mode: <float.h> missing FLT_SNAN macro
Labels new issue
Assignees
Reporter tydeman
    This program:

#include <float.h>
int main(void){
  if(1){
    static float f = FLT_SNAN + FLT_SNAN;
  }
 return 0;
}

gets this error:

. /usr/bin/../lib/clang/20/share/msan_ignorelist.txt
. /usr/bin/../lib/clang/20/include/float.h
test190.c:4:22: error: use of undeclared identifier 'FLT_SNAN'
    4 |     static float f = FLT_SNAN + FLT_SNAN;
      |                      ^
test190.c:4:33: error: use of undeclared identifier 'FLT_SNAN'
    4 |     static float f = FLT_SNAN + FLT_SNAN;
      |                                 ^
2 errors generated.

The flags passed to clang are:
# 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"
# -fsanitize=address added 2019/04/28 => kills compile; not w/ memory
# 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}"

This is on Intel x86_64 Core i5 running Fedora Linux 42.
clang -v gets as it first line:
clang version 20.1.8 (Fedora 20.1.8-4.fc42)

Aside:  If I use the older signaling NAN macro in <math.h> SNANF, the above code cannot be compiled for a different reason.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to