Skip to content

C23 mode: <float.h> missing FLT_SNAN macro #162830

@tydeman

Description

@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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c23clang:headersHeaders provided by Clang, e.g. for intrinsicsconfirmedVerified by a second party

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions