[libc-commits] [libc] [libc] Fix uninitialized variable warning in FrexpTest.h (PR #237263)
via libc-commits
libc-commits at lists.llvm.org
Fri Oct 30 08:46:08 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Victor Campos (vhscampos)
<details>
<summary>Changes</summary>
In Arm baremetal no-FP builds, some variables in `FrexpTest.h` cause uninitialized variable warnings. In some cases it may be false positives that Clang can't reason accurately, but still warns.
In any case, this patch initializes these variables to avoid the warnings altogether.
The ultimate goal is to re-enable `-Werror` in no-FP builds.
---
Full diff: https://github.com/llvm/llvm-project/pull/237263.diff
1 Files Affected:
- (modified) libc/test/src/math/smoke/FrexpTest.h (+3-3)
``````````diff
diff --git a/libc/test/src/math/smoke/FrexpTest.h b/libc/test/src/math/smoke/FrexpTest.h
index 15c17828374c5..ee0775bbd96c3 100644
--- a/libc/test/src/math/smoke/FrexpTest.h
+++ b/libc/test/src/math/smoke/FrexpTest.h
@@ -19,7 +19,7 @@ class FrexpTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
typedef T (*FrexpFunc)(T, int *);
void testSpecialNumbers(FrexpFunc func) {
- int exponent;
+ int exponent = -1;
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, func(aNaN, &exponent));
#ifdef LIBC_FREXP_INF_NAN_EXPONENT
EXPECT_EQ(LIBC_FREXP_INF_NAN_EXPONENT, exponent);
@@ -43,7 +43,7 @@ class FrexpTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
}
void testPowersOfTwo(FrexpFunc func) {
- int exponent;
+ int exponent = 0;
EXPECT_FP_EQ_ALL_ROUNDING(T(0.5), func(T(1.0), &exponent));
EXPECT_EQ(exponent, 1);
@@ -77,7 +77,7 @@ class FrexpTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
}
void testSomeIntegers(FrexpFunc func) {
- int exponent;
+ int exponent = 0;
EXPECT_FP_EQ_ALL_ROUNDING(T(0.75), func(T(24.0), &exponent));
EXPECT_EQ(exponent, 5);
``````````
</details>
https://github.com/llvm/llvm-project/pull/237263
More information about the libc-commits
mailing list