Skip to content

Commit

Permalink
chore: avoid stack overflow in debug tests (leanprover#6103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kha authored Nov 17, 2024
1 parent 24f305c commit 405593e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/include/lean/lean.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ extern "C" {
#if defined(__GNUC__) || defined(__clang__)
#define LEAN_UNLIKELY(x) (__builtin_expect((x), 0))
#define LEAN_LIKELY(x) (__builtin_expect((x), 1))

#ifdef NDEBUG
#define LEAN_ALWAYS_INLINE __attribute__((always_inline))
#else
// We have observed stack frame increases from forced inlining overflowing the stack in debug builds,
// let's leave the decision to the compiler in that case
#define LEAN_ALWAYS_INLINE
#endif

#else
#define LEAN_UNLIKELY(x) (x)
#define LEAN_LIKELY(x) (x)
Expand Down

0 comments on commit 405593e

Please sign in to comment.