[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 79298e8c 1/8: Avoid left shift of a negative
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 79298e8c 1/8: Avoid left shift of a negative signed integer in fdlibm |
Date: |
Fri, 17 Jun 2022 17:16:28 -0400 (EDT) |
branch: master
commit 79298e8c443319077f64410d061b82656ed1095a
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Avoid left shift of a negative signed integer in fdlibm
* fdlibm_expm1.c: Avoid UB.
* objects.make: No longer exclude a target that no longer exhibits UB.
See:
https://lists.nongnu.org/archive/html/lmi/2022-06/msg00061.html
---
fdlibm_expm1.c | 4 +++-
objects.make | 1 -
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/fdlibm_expm1.c b/fdlibm_expm1.c
index 5e05e10f..85327355 100644
--- a/fdlibm_expm1.c
+++ b/fdlibm_expm1.c
@@ -239,7 +239,9 @@ double fdlibm_expm1(double x)
}
if (k <= -2 || k>56) { // suffice to return exp(x)-1
y = one-(e-x);
- SET_HIGH_WORD(y, hi_uint(y) + (k<<20)); // add k to y's exponent
+ // add k to y's exponent, casting to avoid undefined
+ // behavior (left shift of a negative signed integer)
+ SET_HIGH_WORD(y, hi_uint(y) + (int32_t)(((uint32_t)k)<<20));
return y-one;
}
t = one;
diff --git a/objects.make b/objects.make
index bafd4a0f..ddca37e7 100644
--- a/objects.make
+++ b/objects.make
@@ -360,7 +360,6 @@ ifeq (ubsan,$(build_type))
excluded_unit_test_targets += \
actuarial_table_test \
loads_test \
- math_functions_test \
mortality_rates_test \
endif
- [lmi-commits] [lmi] master updated (7d0257a3 -> 876d4b5b), Greg Chicares, 2022/06/17
- [lmi-commits] [lmi] master bcd3e721 2/8: Make relative-error function generally available, Greg Chicares, 2022/06/17
- [lmi-commits] [lmi] master ac211c61 7/8: Write DECIMAL_DIG where it's obviously intended, Greg Chicares, 2022/06/17
- [lmi-commits] [lmi] master 876d4b5b 8/8: Remove unhelpful defect markers [265], Greg Chicares, 2022/06/17
- [lmi-commits] [lmi] master 79298e8c 1/8: Avoid left shift of a negative signed integer in fdlibm,
Greg Chicares <=
- [lmi-commits] [lmi] master 08ec6337 4/8: Genericize relative_error(), Greg Chicares, 2022/06/17
- [lmi-commits] [lmi] master 4eb11e23 5/8: Use relative_error, Greg Chicares, 2022/06/17
- [lmi-commits] [lmi] master 8dfc0348 6/8: Remove an obsolete comment, Greg Chicares, 2022/06/17
- [lmi-commits] [lmi] master 0c922cb6 3/8: Rename rel_err() --> relative_error(), Greg Chicares, 2022/06/17