public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pascal_cuoq at hotmail dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug math/30040] New: nextafter(0.0, 1.0) does not correctly set errno Date: Tue, 24 Jan 2023 10:47:33 +0000 [thread overview] Message-ID: <bug-30040-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=30040 Bug ID: 30040 Summary: nextafter(0.0, 1.0) does not correctly set errno Product: glibc Version: 2.38 Status: UNCONFIRMED Severity: normal Priority: P2 Component: math Assignee: unassigned at sourceware dot org Reporter: pascal_cuoq at hotmail dot com Target Milestone: --- The bug is visible as of this writing at https://godbolt.org/z/P1zGr85vs. The input program and result are attached below. When https://sourceware.org/bugzilla/show_bug.cgi?id=6799 was fixed by commit 85422c2acba , the execution path where x==0 a few lines above the change was forgotten. _____ #include <math.h> #include <stdio.h> #include <errno.h> #include <float.h> #include <fenv.h> int main() { double v; printf("ERANGE = %d\n", ERANGE); // nextafter(0., 1.); feclearexcept(FE_UNDERFLOW); errno = 0; v = nextafter(0., 1.); printf("\nnextafter(0., 1.) = %a\n", v); printf("is subnormal: %d\n", fpclassify(v) == FP_SUBNORMAL); printf("errno = %d\n", errno); if(fetestexcept(FE_UNDERFLOW)) printf("FE_UNDERFLOW\n"); // nextafter(DBL_MIN_SUBNORMAL, 1.); feclearexcept(FE_UNDERFLOW); errno = 0; v = nextafter(v, 1.); printf("\nnextafter(DBL_MIN_SUBNORMAL, 1.) = %a\n", v); printf("is subnormal: %d\n", fpclassify(v) == FP_SUBNORMAL); printf("errno = %d\n", errno); if(fetestexcept(FE_UNDERFLOW)) printf("FE_UNDERFLOW\n"); // nextafter(DBL_MIN_SUBNORMAL, 0.); feclearexcept(FE_UNDERFLOW); errno = 0; v = nextafter(0x0.0000000000001p-1022, 0.); printf("\nnextafter(DBL_MIN_SUBNORMAL, 0.) = %a\n", v); printf("is subnormal: %d\n", fpclassify(v) == FP_SUBNORMAL); printf("errno = %d\n", errno); if(fetestexcept(FE_UNDERFLOW)) printf("FE_UNDERFLOW\n"); // nextafter(DBL_MIN, 0.); feclearexcept(FE_UNDERFLOW); errno = 0; v = nextafter(DBL_MIN, 0.); printf("\nnextafter(DBL_MIN, 0.) = %a\n", v); printf("is subnormal: %d\n", fpclassify(v) == FP_SUBNORMAL); printf("errno = %d\n", errno); if(fetestexcept(FE_UNDERFLOW)) printf("FE_UNDERFLOW\n"); // nextafter(1., 2.); feclearexcept(FE_UNDERFLOW); errno = 0; v = nextafter(1., 2.); printf("\nnextafter(1., 2.) = %a\n", v); printf("is subnormal: %d\n", fpclassify(v) == FP_SUBNORMAL); printf("errno = %d\n", errno); if(fetestexcept(FE_UNDERFLOW)) printf("FE_UNDERFLOW\n"); } _________ ERANGE = 34 nextafter(0., 1.) = 0x0.0000000000001p-1022 is subnormal: 1 errno = 0 FE_UNDERFLOW nextafter(DBL_MIN_SUBNORMAL, 1.) = 0x0.0000000000002p-1022 is subnormal: 1 errno = 34 FE_UNDERFLOW nextafter(DBL_MIN_SUBNORMAL, 0.) = 0x0p+0 is subnormal: 0 errno = 34 FE_UNDERFLOW nextafter(DBL_MIN, 0.) = 0x0.fffffffffffffp-1022 is subnormal: 1 errno = 34 FE_UNDERFLOW nextafter(1., 2.) = 0x1.0000000000001p+0 is subnormal: 0 errno = 0 -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2023-01-24 10:47 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-24 10:47 pascal_cuoq at hotmail dot com [this message] 2023-01-24 10:47 ` [Bug math/30040] " pascal_cuoq at hotmail dot com 2023-03-08 17:23 ` schwab@linux-m68k.org 2023-03-08 17:43 ` pascal_cuoq at hotmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-30040-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).