From 16d50777974df5e8d5c94ba23f914726f06fe36e Mon Sep 17 00:00:00 2001 From: ITHelpDec <34002836+ITHelpDec@users.noreply.github.com> Date: Sun, 4 Jun 2023 15:05:31 +0100 Subject: [PATCH] Change `ptr` to `ptr->next.ptr` Inside - Current implementation exhibits undefined behaviour template inline _LIBCPP_INLINE_VISIBILITY _Tp __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT { #if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS) return __atomic_add_fetch(&__t, -1, __ATOMIC_ACQ_REL); <<<<< //... - Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ff80feda427) --- listings/listing_7.12.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/listings/listing_7.12.cpp b/listings/listing_7.12.cpp index b271612..b86d979 100644 --- a/listings/listing_7.12.cpp +++ b/listings/listing_7.12.cpp @@ -31,7 +31,7 @@ class lock_free_stack { increase_head_count(old_head); node* const ptr=old_head.ptr; - if(!ptr) + if(!ptr->next.ptr) { return std::shared_ptr(); }