public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/103491] New: nextafter does not raise "overflow" and "inexact" floating-point exceptions
@ 2021-11-30 10:39 pavel.morozkin at gmail dot com
2021-11-30 12:16 ` [Bug middle-end/103491] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: pavel.morozkin at gmail dot com @ 2021-11-30 10:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103491
Bug ID: 103491
Summary: nextafter does not raise "overflow" and "inexact"
floating-point exceptions
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: pavel.morozkin at gmail dot com
Target Milestone: ---
Sample code (t0.c):
#include <fenv.h>
#include <math.h>
#pragma STDC FENV_ACCESS ON
int main(void)
{
#if __STDC_IEC_559__ == 1
double d = 1.0;
d = nextafter(d, INFINITY);
return (fetestexcept(FE_INEXACT | FE_INVALID) & (FE_INEXACT | FE_INVALID))
? 0 : 1;
#else
return 0;
#endif
}
Invocation: gcc -std=c11 -pedantic -Wall -Wextra -lm
Expected a.out exit status: 0
Actual a.out exit status: 1
C11, F.10.8.3 The nextafter functions:
> nextafter(x, y) raises the ‘‘overflow’’ and ‘‘inexact’’ floating-point exceptions for x finite and the function value infinite.
Yes, Pragma STDC * (C99 FP) is unimplemented
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785). However, __STDC_IEC_559__
is already 1.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/103491] nextafter does not raise "overflow" and "inexact" floating-point exceptions
2021-11-30 10:39 [Bug c/103491] New: nextafter does not raise "overflow" and "inexact" floating-point exceptions pavel.morozkin at gmail dot com
@ 2021-11-30 12:16 ` pinskia at gcc dot gnu.org
2021-11-30 12:22 ` [Bug tree-optimization/103491] " rguenth at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-30 12:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103491
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |middle-end
Keywords| |wrong-code
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The -O0 case is a glibc issue and should be reported there as gcc just calls
nextafter function.
The -O1 and above seems like a GCC issue though.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/103491] nextafter does not raise "overflow" and "inexact" floating-point exceptions
2021-11-30 10:39 [Bug c/103491] New: nextafter does not raise "overflow" and "inexact" floating-point exceptions pavel.morozkin at gmail dot com
2021-11-30 12:16 ` [Bug middle-end/103491] " pinskia at gcc dot gnu.org
@ 2021-11-30 12:22 ` rguenth at gcc dot gnu.org
2021-11-30 23:20 ` joseph at codesourcery dot com
2021-12-01 18:22 ` pavel.morozkin at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-30 12:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103491
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-11-30
Component|middle-end |tree-optimization
Status|UNCONFIRMED |NEW
CC| |jsm28 at gcc dot gnu.org,
| |rguenth at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed with -frounding-math and optimization where we simply elide
the nextafter call (and its side-effects). I think the idea is that
-ftrapping-math should preserve such calls (but that's default on even).
-frounding-math is documented to be required for FENV_ACCESS.
Also confirmed as a glibc bug in 2.31 with -O0 where we call nextafter ().
The manpage isn't too informative on whether your expectation is valid.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/103491] nextafter does not raise "overflow" and "inexact" floating-point exceptions
2021-11-30 10:39 [Bug c/103491] New: nextafter does not raise "overflow" and "inexact" floating-point exceptions pavel.morozkin at gmail dot com
2021-11-30 12:16 ` [Bug middle-end/103491] " pinskia at gcc dot gnu.org
2021-11-30 12:22 ` [Bug tree-optimization/103491] " rguenth at gcc dot gnu.org
@ 2021-11-30 23:20 ` joseph at codesourcery dot com
2021-12-01 18:22 ` pavel.morozkin at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: joseph at codesourcery dot com @ 2021-11-30 23:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103491
--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
This testcase is incorrect. This call to nextafter has a finite result,
so it's correct that no exceptions are raised and so an exit status of 1
from the provided testcase is what should be expected.
A GCC bug could only be demonstrated if the call were elided for arguments
for which overflow or underflow occurs (such as (DBL_MAX, INFINITY) or
(DBL_MIN, 0) or (DBL_TRUE_MIN, 0)). I haven't tested whether that is the
case.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/103491] nextafter does not raise "overflow" and "inexact" floating-point exceptions
2021-11-30 10:39 [Bug c/103491] New: nextafter does not raise "overflow" and "inexact" floating-point exceptions pavel.morozkin at gmail dot com
` (2 preceding siblings ...)
2021-11-30 23:20 ` joseph at codesourcery dot com
@ 2021-12-01 18:22 ` pavel.morozkin at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: pavel.morozkin at gmail dot com @ 2021-12-01 18:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103491
--- Comment #4 from Pavel M <pavel.morozkin at gmail dot com> ---
To: joseph@codesourcery.com
Re: This testcase is incorrect.
Indeed. The F.10.8.3 was misunderstood.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-12-01 18:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30 10:39 [Bug c/103491] New: nextafter does not raise "overflow" and "inexact" floating-point exceptions pavel.morozkin at gmail dot com
2021-11-30 12:16 ` [Bug middle-end/103491] " pinskia at gcc dot gnu.org
2021-11-30 12:22 ` [Bug tree-optimization/103491] " rguenth at gcc dot gnu.org
2021-11-30 23:20 ` joseph at codesourcery dot com
2021-12-01 18:22 ` pavel.morozkin at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).