diff --git a/ctl/shared_ptr.h b/ctl/shared_ptr.h index e85429c48..019d6fb29 100644 --- a/ctl/shared_ptr.h +++ b/ctl/shared_ptr.h @@ -43,8 +43,8 @@ incref(size_t* r) noexcept #ifdef NDEBUG __atomic_fetch_add(r, 1, __ATOMIC_RELAXED); #else - size_t refs = __atomic_fetch_add(r, 1, __ATOMIC_RELAXED); - if (refs > ((size_t)-1) >> 1) + ssize_t refs = __atomic_fetch_add(r, 1, __ATOMIC_RELAXED); + if (refs < 0) __builtin_trap(); #endif }