Skip to content

refactor: not_null constexpr in debug builds - #13

Merged
codethinki merged 2 commits into
masterfrom
refactor/not-null-constexpr
Oct 16, 2026
Merged

codethinki merged 2 commits into
masterfrom
refactor/not-null-constexpr

Conversation

@codethinki

@codethinki codethinki commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

not_null's constructor and checkVal were constexpr in release builds only (CTH_RELEASE_CONSTEXPR).

In constant evaluation the CTH_CRITICAL check only runs its failure branch for a null value:

  • a valid value evaluates at compile time
  • a null value is a compile error at the CTH_CRITICAL line, at run time debug builds still abort

CTH_RELEASE_CONSTEXPR had no other use and is removed.

Tested locally with gcc 16 and clang 23 (gcc_debug, clang_debug, gcc_release, clang_release: 264/264 tests).
New test not_null.constexpr builds and copies a not_null in a static_assert.
MSVC is only covered by the Windows CI.

The constructor and checkVal were constexpr in release builds only (CTH_RELEASE_CONSTEXPR).
In constant evaluation the CTH_CRITICAL check only runs its failure branch for a null value,
so a valid value evaluates at compile time and a null value is a compile error.
CTH_RELEASE_CONSTEXPR had no other use and is removed, the cthm copy too.
@codethinki
codethinki merged commit 4364b79 into master Oct 16, 2026
6 checks passed
@codethinki
codethinki deleted the refactor/not-null-constexpr branch October 16, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant