From: Ilya Maykov Date: Fri, 23 Jun 2017 22:43:48 +0000 (-0700) Subject: fix UBSAN failure in atomic_shared_ptr_test X-Git-Tag: v2017.06.26.00~5 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d71b7361e718b3ee9ed720ae65f6223dbb9823a1;p=folly.git 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 --- 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{})); }