This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix y0 and y1 exception handling for zero input [BZ #21134]
- From: Joseph Myers <joseph at codesourcery dot com>
- To: "Gabriel F. T. Gomes" <gftg at linux dot vnet dot ibm dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Mon, 13 Feb 2017 18:13:57 +0000
- Subject: Re: [PATCH] Fix y0 and y1 exception handling for zero input [BZ #21134]
- Authentication-results: sourceware.org; auth=none
- References: <1486947652-19405-1-git-send-email-gftg@linux.vnet.ibm.com>
On Sun, 12 Feb 2017, Gabriel F. T. Gomes wrote:
> if ((ix | lx) == 0)
> - return -HUGE_VAL + x; /* -inf and overflow exception. */
> + {
> + __feraiseexcept (FE_DIVBYZERO);
> + return -HUGE_VAL + x; /* -inf and overflow exception. */
> + }
Rather than explicitly raising the exception I think it would be better to
e.g. return -1 / fabs (x) (using the right fabs function for the type in
question) or -1 / 0.0 (appropriately typed zero). (And the comment
referencing the overflow exception is incorrect.)
--
Joseph S. Myers
joseph@codesourcery.com