#pragma STDC FENV_ROUND FE_TONEAREST gives misleading warning
The statement: #pragma STDC FENV_ROUND FE_TONEAREST
Gets: warning: expected identifier in '#pragma FENV_ROUND' - ignored [-Wignored-pragmas] which is misleading.
- The 'STDC' got dropped in the message.
- FE_TONEAREST is a valid 'direction' as per the C standard.
If the pragma is not supported, the warning should say so. If the pragma is supported, there should be no warning.
I see the following (https://godbolt.org/z/P4Woh3z8Y):
<source>:1:38: warning: pragma STDC FENV_ROUND is not supported [-Wunknown-pragmas]
1 | #pragma STDC FENV_ROUND FE_TONEAREST
| ^
1 warning generated.
Compiler returned: 0
Can you give reproduction steps or a godbolt link?
Here is the program:
#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){ return 0; }
Here are the command line flags:
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}"
Happens only if <fenv.h> is included first because it #defines FE_TONEAREST.
Minimal reproducer (https://godbolt.org/z/E5cbPrebe):
#define FE_TONEAREST 0
#pragma STDC FENV_ROUND FE_TONEAREST
@efriedma-quic @keinflue I’d like to work on this issue.
@Vinayak-RZ I do not have the ability to assign issues. However, you can suggest a PR or ask questions without being assigned.
@Vinayak-RZ I do not have the ability to assign issues. However, you can suggest a PR or ask questions without being assigned.
We don't assign issues until you have a PR and we have verified that it looks like it is moving in the right direction.