[llvm] [ADT] Fix a minor build error (PR #104840)
Dmitry Yanovsky via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 12:44:52 PDT 2024
https://github.com/kerambyte created https://github.com/llvm/llvm-project/pull/104840
A quick follow-up fix for https://github.com/llvm/llvm-project/pull/99403
Buildbot [reported](https://lab.llvm.org/buildbot/#/builders/168/builds/2330) an error:
```
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/ADT/FunctionExtrasTest.cpp:320:8: error: variable 'ptr' is uninitialized when used here [-Werror,-Wuninitialized]
320 | [ptr](void *self) {
| ^~~
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/ADT/FunctionExtrasTest.cpp:318:12: note: initialize the variable 'ptr' to silence this warning
318 | void *ptr;
| ^
| = nullptr
1 error generated.
```
So that PR does exactly what's sugested.
>From 196e61b333a89679a3976d855236ad4304b97ce2 Mon Sep 17 00:00:00 2001
From: kerambyte <kerambyte at gmail.com>
Date: Mon, 19 Aug 2024 20:43:09 +0100
Subject: [PATCH] fix build error
---
llvm/unittests/ADT/FunctionExtrasTest.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/unittests/ADT/FunctionExtrasTest.cpp b/llvm/unittests/ADT/FunctionExtrasTest.cpp
index f64b888dbe1591..9809a92daac724 100644
--- a/llvm/unittests/ADT/FunctionExtrasTest.cpp
+++ b/llvm/unittests/ADT/FunctionExtrasTest.cpp
@@ -316,7 +316,7 @@ TEST(UniqueFunctionTest, InlineStorageWorks) {
// We do assume a couple of implementation details of the unique_function here:
// - It can store certain small-enough payload inline
// - Inline storage size is at least >= sizeof(void*)
- void *ptr;
+ void *ptr = nullptr;
unique_function<void(void *)> UniqueFunctionWithInlineStorage{
[ptr](void *self) {
auto mid = reinterpret_cast<uintptr_t>(&ptr);
More information about the llvm-commits
mailing list