# 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.

[Video](https://resources.jetbrains.com/help/img/idea/2026.2/cl_constexpr_debugger_overview.mp4)

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](stepping-through-the-program.html) 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.

Procedure: Start debugging

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

```CPLUSPLUS
#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 ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.startDebugger.png) icon next to the `constexpr` declarator or `static_assert` to start debugging:

![Start debugging](https://resources.jetbrains.com/help/img/idea/2026.2/cl_constexpr_debugger_start.png)

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

![Step into](https://resources.jetbrains.com/help/img/idea/2026.2/cl_constexpr_debugger_basic_actions.png)

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

![Step backward](https://resources.jetbrains.com/help/img/idea/2026.2/cl_constexpr_debugger_step_back.png)

4. Inspect the state:

* Hover over `this->memo` in the editor to watch how the array fills during construction: ![Inspect memo](https://resources.jetbrains.com/help/img/idea/2026.2/cl_constexpr_debugger_memo.png)

* Evaluate expressions or types by pressing `Alt+F8` (Windows), `⌥ F8` (macOS), `⌥ F8` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ L` (macOS System Shortcuts), `Alt+F8` (XWin), `Alt+Shift+8` (GNOME), `Alt+Shift+8` (KDE), `Alt+F8` (Emacs), `Alt+F8` (Sublime Text), `⌥ F8` (Sublime Text (macOS)), `⌥ F8` (Xcode), `Shift+F9` (Visual Studio), `⇧ F9` (Visual Studio (macOS)), `Shift+F9` (ReSharper), `⇧ F9` (ReSharper (macOS)), `Alt+F8` (QtCreator), `⌥ F8` (QtCreator (macOS)), `Ctrl+F9` (NetBeans), `Ctrl+U` (Eclipse), `⌘ U` (Eclipse (macOS)): ![Evaluate expression](https://resources.jetbrains.com/help/img/idea/2026.2/cl_constexpr_debugger_evaluate.png)

* Check the `Threads & Variables` pane to see `this`, locals like `i`, and recent returns: ![Inspect variables](https://resources.jetbrains.com/help/img/idea/2026.2/cl_constexpr_debugger_variables.png)

* Use the `Frame` pane to see the call stack and navigate to the source code: ![Inspect call stack](https://resources.jetbrains.com/help/img/idea/2026.2/cl_constexpr_debugger_call_stack.png)

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

![Inspect results](https://resources.jetbrains.com/help/img/idea/2026.2/cl_constexpr_debugger_result.png)

Procedure: 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](https://resources.jetbrains.com/help/img/idea/2026.2/cl_constexpr_debugger_error_popup.png) 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](https://resources.jetbrains.com/help/img/idea/2026.2/cl_constexpr_debugger_non_constexpr.png)

## 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](https://jb.gg/cpp_constexpr_evaluation).

## See also

### Related

[Debug](debugging-code.html) [Start/pause/stop debug session](starting-the-debugger-session.html) [Step through](stepping-through-the-program.html) [Examine suspended program](examining-suspended-program.html)

