You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ks...@apache.org on 2021/05/17 11:37:15 UTC

[arrow] 09/13: ARROW-12663: [C++] Fix a cuda 11.2 compiler segfault

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

kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git

commit 6a2915e0f69e5d59d343a68aab22f8bb008b8faa
Author: GALI PREM SAGAR <sa...@gmail.com>
AuthorDate: Mon May 10 17:17:32 2021 +0200

    ARROW-12663: [C++] Fix a cuda 11.2 compiler segfault
    
    With the nvcc 11.2 compiler we have a segfault when we have a copy and move assignment operator :
    ```
    using Impl::operator=;
    ```
    before a move-assignment operator:
    
     ```
    Variant& operator=(Variant&& other) noexcept {
      this->destroy();
      other.move_to(this);
      return *this;
    }
    ```
    
    A minimal repro :
    
    With a segfault : https://godbolt.org/z/h9eYv6zas
    
    Without a segfault : https://godbolt.org/z/oWhK5qPd8
    
    In this PR, as a workaround, we have essentially re-ordered the move-assignment of `Variant` before `using Impl::operator=;`.
    
    Closes #10257 from galipremsagar/patch-2
    
    Authored-by: GALI PREM SAGAR <sa...@gmail.com>
    Signed-off-by: Antoine Pitrou <an...@python.org>
---
 cpp/src/arrow/util/variant.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/cpp/src/arrow/util/variant.h b/cpp/src/arrow/util/variant.h
index 89f39ab..962254a 100644
--- a/cpp/src/arrow/util/variant.h
+++ b/cpp/src/arrow/util/variant.h
@@ -262,18 +262,17 @@ class Variant : detail::VariantImpl<Variant<T...>, T...>,
 
   Variant(const Variant& other) = default;
   Variant& operator=(const Variant& other) = default;
-
-  using Impl::Impl;
-  using Impl::operator=;
-
-  Variant(Variant&& other) noexcept { other.move_to(this); }
-
   Variant& operator=(Variant&& other) noexcept {
     this->destroy();
     other.move_to(this);
     return *this;
   }
 
+  using Impl::Impl;
+  using Impl::operator=;
+
+  Variant(Variant&& other) noexcept { other.move_to(this); }
+
   ~Variant() {
     static_assert(offsetof(Variant, data_) == 0, "(void*)&Variant::data_ == (void*)this");
     this->destroy();