Skip to content

Commit

Permalink
Fix NullPtrInfo warnings on GCC 11, #646
Browse files Browse the repository at this point in the history
  • Loading branch information
kaetemi committed Apr 22, 2022
1 parent 04a7f9e commit 4d1708a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nel/include/nel/misc/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,13 @@ extern bool _assertex_stop_1(bool &ignoreNextTime);
#define nlassume(exp) do { } while (0)
#endif

#if defined(NL_COMP_GCC) && (GCC_VERSION >= 40500)
// This may evaluate the expression at runtime if it has side effects, so it is not a desirable nlassume implementation in release mode
#define nlassumeex(exp) do { if (!(exp)) __builtin_unreachable(); } while (0)
#else
#define nlassumeex(exp) nlassume(exp)
#endif

#ifdef NL_NO_DEBUG
# define nlassert(exp) nlassume(exp)
# define nlassertonce(exp) nlassume(exp)
Expand Down
2 changes: 2 additions & 0 deletions nel/include/nel/misc/smart_ptr_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ SMART_INLINE void CRefPtr<T>::unRef() const
}
else
{
// Guarantueed by !pinfo->IsNullPtrInfo
nlassumeex(pinfo != &CRefCount::NullPtrInfo);
// If the CRefPtr still point to a valid object.
if(pinfo->Ptr)
{
Expand Down

0 comments on commit 4d1708a

Please sign in to comment.