This is an automated email from the ASF dual-hosted git repository.

paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 8a9f1af8 fix: Fix valgrind error suggesting use of an uninitialized 
value (#750)
8a9f1af8 is described below

commit 8a9f1af8da1196f1906cdc4a95ffc7bdde3cb9c8
Author: Dewey Dunnington <[email protected]>
AuthorDate: Sat May 3 14:25:44 2025 -0500

    fix: Fix valgrind error suggesting use of an uninitialized value (#750)
    
    I'm not sure that anything was actually wrong here, but writing it
    differently helped valgrind understand what's going on. I also added a
    pin for meson since the latest version results in failing CI when
    running valgrind (and opened #753 to track removing the pin).
    
    Closes #749.
---
 .github/workflows/build-and-test.yaml | 11 ++++++-----
 src/nanoarrow/hpp/view.hpp            | 20 +++++++++++---------
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/build-and-test.yaml 
b/.github/workflows/build-and-test.yaml
index f420a68b..517ee4ec 100644
--- a/.github/workflows/build-and-test.yaml
+++ b/.github/workflows/build-and-test.yaml
@@ -126,10 +126,9 @@ jobs:
           name: nanoarrow-memcheck
           path: build/Testing/Temporary/MemoryChecker.*.log
 
-  verify-meson:
-    name: meson-build
-    # Workaround until https://github.com/apache/arrow-nanoarrow/issues/663 is 
solved
-    # (after which we can use ubuntu-latest)
+  meson-build:
+    # Can't quite be ubuntu-latest yet
+    # https://github.com/apache/arrow-nanoarrow/issues/753
     runs-on: ubuntu-22.04
     steps:
       - uses: actions/checkout@v4
@@ -142,8 +141,10 @@ jobs:
           sudo apt-get update && sudo apt-get install -y gcovr ninja-build 
valgrind
 
       - name: Install meson
+        # Meson 1.8.0 breaks build
+        # https://github.com/apache/arrow-nanoarrow/issues/753
         run: |
-          python3 -m pip install meson
+          python3 -m pip install "meson<1.8.0"
 
       - name: Cache Arrow C++ Build
         id: cache-arrow-build
diff --git a/src/nanoarrow/hpp/view.hpp b/src/nanoarrow/hpp/view.hpp
index b9197583..0e38b353 100644
--- a/src/nanoarrow/hpp/view.hpp
+++ b/src/nanoarrow/hpp/view.hpp
@@ -32,19 +32,24 @@ struct Nothing {};
 template <typename T>
 class Maybe {
  public:
-  Maybe() : nothing_(Nothing()), is_something_(false) {}
+  Maybe() : is_something_(false) {}
   Maybe(Nothing) : Maybe() {}
 
   Maybe(T something)  // NOLINT(google-explicit-constructor)
-      : something_(something), is_something_(true) {}
+      : is_something_(true), something_(something) {}
 
   explicit constexpr operator bool() const { return is_something_; }
 
   const T& operator*() const { return something_; }
 
   friend inline bool operator==(Maybe l, Maybe r) {
-    if (l.is_something_ != r.is_something_) return false;
-    return l.is_something_ ? l.something_ == r.something_ : true;
+    if (l.is_something_) {
+      return r.is_something_ && l.something_ == r.something_;
+    } else if (r.is_something_) {
+      return l.is_something_ && l.something_ == r.something_;
+    } else {
+      return l.is_something_ == r.is_something_;
+    }
   }
   friend inline bool operator!=(Maybe l, Maybe r) { return !(l == r); }
 
@@ -55,11 +60,8 @@ class Maybe {
   // is_trivially_copyable<T>::value
   static_assert(std::is_trivially_destructible<T>::value, "");
 
-  union {
-    Nothing nothing_;
-    T something_;
-  };
-  bool is_something_;
+  bool is_something_{};
+  T something_{};
 };
 
 template <typename Get>

Reply via email to