From d71b7361e718b3ee9ed720ae65f6223dbb9823a1 Mon Sep 17 00:00:00 2001 From: Ilya Maykov Date: Fri, 23 Jun 2017 15:43:48 -0700 Subject: [PATCH] fix UBSAN failure in atomic_shared_ptr_test Summary: Fix UBSAN failure in atomic_shared_ptr_test by using reinterpret_cast instead of static_cast. Reviewed By: yfeldblum Differential Revision: D5314116 fbshipit-source-id: 8479c9c4bdeeb155067a3de75efe4e97c36519e5 --- folly/experimental/detail/AtomicSharedPtr-detail.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/folly/experimental/detail/AtomicSharedPtr-detail.h b/folly/experimental/detail/AtomicSharedPtr-detail.h index bd416cb0..02d8be02 100644 --- a/folly/experimental/detail/AtomicSharedPtr-detail.h +++ b/folly/experimental/detail/AtomicSharedPtr-detail.h @@ -68,8 +68,8 @@ class shared_ptr_internals { return (T*)inplace; } // Could also be a _Sp_counted_deleter, but the layout is the same - auto ptr = - static_cast*>(base); + using derived_type = std::_Sp_counted_ptr; + auto ptr = reinterpret_cast(base); return (T*)(ptr->*fieldPtr(access_counted_ptr_ptr{})); } -- 2.34.1