CLion 2025.3 Help

Constexpr Debugger

The Constexpr Debugger provides insights into compile-time evaluations, particularly for constexpr and consteval code. It allows you to stay in the compiler's world and see exactly what happens during evaluation.

Here is what you currently can do with the Constexpr Debugger:

  • Start step-by-step debugging from the gutter by clicking the Debug button next to static_assert(...) or a constexpr declarator to check how it was evaluated or why it failed.

  • Use the same actions as in the regular debugger, such as Step Into or Step Over. Additionally, you can use Step Backward, the compile-time reverse stepping feature.

  • See what the compiler sees: the call stack, locals, last returns, and template arguments of the current instantiation.

  • Hover over a variable to see its values, use Evaluate Expression, or navigate to the source code from the call stack.

  • Inspect the entire context when constant evaluation fails to determine when and why it occurred.

Key debugging features

The following sections is an overview of the essential actions that you can perform when debugging constexpr code.

Start debugging

As a code example, let's consider this implementation of the compile-time Fibonacci cache:

#include <array> template<std::size_t N> struct FibCache { std::array<int, N + 1> memo{}; constexpr FibCache() { memo[0] = 0; memo[1] = 1; for (std::size_t i = 2; i <= N; ++i) memo[i] = memo[i - 1] + memo[i - 2]; } constexpr int operator()(int n) const { return memo[n]; } }; constexpr int get_fibonacci(int n) { FibCache<8> cache; auto result = cache(n); return result; } constexpr int k = get_fibonacci(6); static_assert(get_fibonacci(6) == 8, "ok");
  1. Click the icon next to the constexpr declarator or static_assert to start debugging:

    Start debugging
  2. Use the standard Step Into or Step Over debugger actions to evaluate expressions:

    Step into
  3. Use Step Backward to navigate back through each step of the compile-time evaluation:

    Step backward
  4. Inspect the state:

    • Hover over this->memo in the editor to watch how the array fills during construction:

      Inspect memo
    • Evaluate expressions or types by pressing Alt+F8:

      Evaluate expression
    • Check the Threads & Variables pane to see this, locals like i, and recent returns:

      Inspect variables
    • Use the Frame pane to see the call stack and navigate to the source code:

      Inspect call stack
  5. Check the result in the Threads & Variables pane after the constructor has precomputed all the Fibonacci numbers:

    Inspect results

Diagnose and fix compile-time errors

  • When evaluation fails, for example, because of incorrect code logic, CLion highlights the error. When you hover over it, a popup appears with the problem explanation:

    Error popup

    If it is still unclear what causes the error and at what step it occurs, click Run evaluation until failure to debug it. The Constexpr Debugger will stop at the failed evaluation and show you the error message and the context.

  • When an expression cannot be evaluated at compile time – for example, when a non-constexpr function is called – CLion highlights the error, both in the editor and during debugging:

    Non-constexpr evaluation

    Limitations

    • Breakpoints and Run to Cursor / Force Run to Cursor are not supported in constexpr evaluation.

    • Some constructs aren’t yet supported by our constexpr evaluator. You can track progress and upvote related issues on YouTrack.

    23 February 2026