From: Lang Hames Date: Thu, 3 Nov 2016 22:01:47 +0000 (+0000) Subject: [Support] Fix a segfault in llvm::Expected. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4373dd0316a6d3fa4572bfa9d1fbd9f83b80b865;p=llvm [Support] Fix a segfault in llvm::Expected. This fixes a mismatch between the declared error_type and the type used with the placement new that initializes the field. Patch by Yichao Yu. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285970 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/Error.h b/include/llvm/Support/Error.h index 0f9b3260385..cdd46a84b5c 100644 --- a/include/llvm/Support/Error.h +++ b/include/llvm/Support/Error.h @@ -147,7 +147,7 @@ class LLVM_NODISCARD Error { // Expected needs to be able to steal the payload when constructed from an // error. - template class Expected; + template friend class Expected; public: /// Create a success value. Prefer using 'Error::success()' for readability @@ -642,7 +642,7 @@ public: { assert(Err && "Cannot create Expected from Error success value."); - new (getErrorStorage()) Error(std::move(Err)); + new (getErrorStorage()) error_type(Err.takePayload()); } /// Create an Expected success value from the given OtherT value, which