Commit 1fe992d
tgamma: raise FE_OVERFLOW (not FE_DIVBYZERO) on overflow (#325)
openlibm signals math errors via FP exception flags, not errno
(math_errhandling == MATH_ERREXCEPT), and tgamma already raised the right
flags everywhere except large-argument overflow: the x > 171.63 path
returned `x / zero`, which yields +Inf but raises FE_DIVBYZERO. That flag
is reserved for the pole at x == 0; a finite argument whose true gamma
exceeds DBL_MAX is an overflow and must raise FE_OVERFLOW (as the function
comment already documents, and as glibc does).
Return `x * 0x1p1023` instead, which overflows to +Inf and raises
FE_OVERFLOW. The pole (FE_DIVBYZERO) and negative-integer domain error
(FE_INVALID) were already correct and are unchanged.
This keeps the library consistent with its own math_errhandling rather
than introducing errno, which no other openlibm function sets.
Adds test/regression/test-325.c, which verifies the exception for each
error class against the result value; it self-checks that the
environment tracks FP flags first (qemu-user emulates them unreliably on
some arches, cf. #347) and skips otherwise.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 43f291e commit 1fe992d
2 files changed
Lines changed: 73 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
135 | 142 | | |
136 | 143 | | |
137 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
0 commit comments