[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 Campbell changed: What|Removed |Added CC||rlcamp.pdx at gmail dot com --- Comment #19 from Campbell --- Regardless of the wider issue, it would be nice to get STDC CX_LIMITED_RANGE implemented. Is there something specific blocking this?
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 Eric Gallager changed: What|Removed |Added Severity|enhancement |normal --- Comment #18 from Eric Gallager --- (In reply to Vincent Lefèvre from comment #17) > (In reply to Pavel M from comment #16) > > Note: The #pragma STDC FENV_ACCESS is unknown and ignored (leading to FP > > issues), however, the __STDC_IEC_559__ is defined to 1. Confused. > > Yes, and IMHO, with __STDC_IEC_559__ defined to 1, this is a much more > severe issue. This PR should not be regarded as an enhancement, but as a > real bug OK, I put the importance back to "normal"
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 --- Comment #17 from Vincent Lefèvre --- (In reply to Pavel M from comment #16) > Note: The #pragma STDC FENV_ACCESS is unknown and ignored (leading to FP > issues), however, the __STDC_IEC_559__ is defined to 1. Confused. Yes, and IMHO, with __STDC_IEC_559__ defined to 1, this is a much more severe issue. This PR should not be regarded as an enhancement, but as a real bug (this would be an enhancement only if when __STDC_IEC_559__ is defined to 1, there would be a lack of optimization).
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 --- Comment #16 from Pavel M --- Note: The #pragma STDC FENV_ACCESS is unknown and ignored (leading to FP issues), however, the __STDC_IEC_559__ is defined to 1. Confused.
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 --- Comment #15 from Vincent Lefèvre --- (In reply to Pavel M from comment #14) > The "warning: ignoring '#pragma STDC FENV_ACCESS' [-Wunknown-pragmas]" > probably needs to be generated by default Getting the warning on "#pragma STDC FENV_ACCESS OFF" is useless. The issue comes from the fact that the FENV_ACCESS is OFF by default and you want to set it to ON; there should be a warning in this case, but only in this case. Concerning the other pragmas, this also depends on their default state. For instance, since commit 6dbe09581a1349498f6b4546f68cb9fd3205e120[*], the STDC FP_CONTRACT pragma is set to OFF by default when a standard mode is provided (e.g. -std=c17), so that the warning on this pragma is not needed in this case (whether the user sets it to ON or OFF). [*] https://gcc.gnu.org/git/?p=gcc.git=commit;h=6dbe09581a1349498f6b4546f68cb9fd3205e120
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 --- Comment #14 from Pavel M --- To: Vincent Lefèvre Re: the warnings are useless. The "warning: ignoring '#pragma STDC FENV_ACCESS' [-Wunknown-pragmas]" probably needs to be generated by default (i.e. not with -Wall) because now gcc silently miscompiles the following (though unusual) code: /* t0.c */ #include #include #include #pragma STDC FENV_ACCESS ON int main( void ) { volatile double d1 = DBL_MAX; volatile double d2 = DBL_MAX; #ifdef __STDC__ printf("__STDC__ %d\n", __STDC__); #endif #ifdef __STDC_VERSION__ printf("__STDC_VERSION__ %ld\n", __STDC_VERSION__); #endif #ifdef __STDC_IEC_559__ printf("__STDC_IEC_559__ %d\n", __STDC_IEC_559__); #endif if (feclearexcept( FE_ALL_EXCEPT ) != 0) { printf("error: feclearexcept( FE_ALL_EXCEPT ) failed\n"); return 1; } ( void )( d1 * d2 ); if (fetestexcept( FE_OVERFLOW ) == 0) { printf("error: no FE_OVERFLOW is raised\n"); return 2; } return 0; } Invocation: gcc t0.c -std=c11 -pedantic -lm Execution: ./a.out Expected output: __STDC__ 1 __STDC_VERSION__ 201710 __STDC_IEC_559__ 1 Actual output: __STDC__ 1 __STDC_VERSION__ 201710 __STDC_IEC_559__ 1 error: no FE_OVERFLOW is raised
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 Pavel M changed: What|Removed |Added CC||pavel.morozkin at gmail dot com --- Comment #12 from Pavel M --- As far as I understand, support of #pragma STDC xxx is required by the C standard for hosted implementation. If so, then it is worth reaching conformance to increase the priority of this issue. It is logical for the end users to expect the support of #pragma STDC xxx. Now they see: t888.c:3: warning: ignoring ‘#pragma STDC FP_CONTRACT’ [-Wunknown-pragmas] t888.c:4: warning: ignoring ‘#pragma STDC FENV_ACCESS’ [-Wunknown-pragmas] t888.c:5: warning: ignoring ‘#pragma STDC CX_LIMITED_RANGE’ [-Wunknown-pragmas] Invoked with: gcc t888.c -c -std=c11 -Wall.
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 --- Comment #13 from Vincent Lefèvre --- If the default state of these pragmas (at least with options like -std=c11) is respectively "off", "on", "off", then changing the pragma state can safely be ignored by the implementation, as implementations are not obliged to optimize as allowed by the new pragma state. Thus, in such a case, the warnings are useless.
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 --- Comment #11 from Andrew Pinski --- I have idea on how to fix the FENV_ACCESS issue (for gimple), basically you add an extra virtual use op for float gimples and virtual define for functions and inline-asm. Now I am not going to implement this but I want to record it somewhere.
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 --- Comment #10 from joseph at codesourcery dot com --- On Fri, 21 Feb 2020, vincent-gcc at vinc17 dot net wrote: > Concerning the STDC FP_CONTRACT pragma, implementing it would not be > sufficient. GCC would also need to restrict how it does contraction, as it > currently does not contract only expressions, but also sequences of > expressions, which is invalid. Example: Note that -ffp-contract=on is currently equivalent to -ffp-contract=off for this reason. It's only -ffp-contract=fast that contracts outside expressions (and C standards conformance modes disable contraction).
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 --- Comment #9 from Richard Biener --- Note fixin(In reply to Vincent Lefèvre from comment #8) > Concerning the STDC FP_CONTRACT pragma, implementing it would not be > sufficient. GCC would also need to restrict how it does contraction, as it > currently does not contract only expressions, but also sequences of > expressions, which is invalid. Example: > > double foo (double a, double b, double c) > { > double p = a * b; > return p + c; > } > > Since a * b and p + c are separate expressions, contraction to FMA must not > be done according to the C standard. But when contraction is allowed, GCC > generates a FMA on my x86_64 processor: > > .cfi_startproc > vfmadd132sd %xmm1, %xmm2, %xmm0 > ret > .cfi_endproc Note fixing that is as easy as wrapping FP expressions in PAREN_EXPR to denote which ones are separate. PAREN_EXPRs also serve as association barriers and the FE needs to decide what FP optimization flag elides them where exactly (the middle-end leaves them in place even with -ffast-math).
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 --- Comment #8 from Vincent Lefèvre --- Concerning the STDC FP_CONTRACT pragma, implementing it would not be sufficient. GCC would also need to restrict how it does contraction, as it currently does not contract only expressions, but also sequences of expressions, which is invalid. Example: double foo (double a, double b, double c) { double p = a * b; return p + c; } Since a * b and p + c are separate expressions, contraction to FMA must not be done according to the C standard. But when contraction is allowed, GCC generates a FMA on my x86_64 processor: .cfi_startproc vfmadd132sd %xmm1, %xmm2, %xmm0 ret .cfi_endproc
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785 Vincent Lefèvre changed: What|Removed |Added CC||vincent-gcc at vinc17 dot net --- Comment #7 from Vincent Lefèvre --- For the STDC FENV_ACCESS pragma specifically, there is PR34678. For the STDC FP_CONTRACT pragma, there is PR37845, which was fixed by r204460, though things could be improved in the future as the pragma is actually ignored: it's just that the default is now OFF in standard modes to be C99/C11 conforming. In the non-standard modes, one now misses the warning: PR68499.
[Bug c/20785] Pragma STDC * (C99 FP) unimplemented
--- Comment #6 from rguenth at gcc dot gnu dot org 2009-01-30 07:19 --- *** Bug 39036 has been marked as a duplicate of this bug. *** -- rguenth at gcc dot gnu dot org changed: What|Removed |Added CC||tydeman at tybor dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785