Use unsigned-signed conversion for refs test (#1272)

This commit is contained in:
Steven Dee (Jōshin) 2024-09-01 16:45:11 -04:00 committed by GitHub
parent 75e161b27b
commit 389d565d46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}