Quick answer: check halts the game when its condition is false and is compiled out of Test and Shipping builds, expression included. verify is the same assert, but its expression still runs in Shipping. ensure does not halt: it logs a callstack, sends a non-fatal report once per call site, and returns the condition so you can branch on it. Use check for invariants, verify when the expression has a side effect, and ensure for surprises you can recover from.
All three macros look alike in code and behave nothing alike in a build. One of them stops the process, one of them stops it only in some configurations while still running its argument in all of them, and one never stops anything but can freeze the game thread for a moment the first time it fires. The differences decide whether a bug is a clean crash at the right line, a silent skip, or a call that vanished from your Shipping build. This guide puts the behaviour in one table, shows what each failure looks like in a log, and gives a rule for choosing.
- The whole thing in one table
- What switches them on and off
- check: for invariants
- verify: when the expression must run
- ensure: for surprises you can survive
- The control-flow checks
- Which one to use
- Should you enable checks in Shipping
- Blueprint has no asserts
- What reaches Bugnet
- Related guides
- Frequently asked questions
The whole thing in one table
The macros live in Engine/Source/Runtime/Core/Public/Misc/AssertionMacros.h. Defaults for a packaged game, UE 5.x:
| Macro | When the condition is false | Expression runs in Shipping | Debug | Development | Test | Shipping |
|---|---|---|---|---|---|---|
check, checkf | Fatal error, process ends | No | On | On | Off | Off |
checkSlow, checkfSlow | Fatal error, process ends | No | On | Off | Off | Off |
checkNoEntry, checkNoReentry, checkNoRecursion, unimplemented | Fatal error when the line is reached (or reached twice) | No expression | On | On | Off | Off |
verify, verifyf | Fatal error, process ends | Yes | On | On | Runs, not asserted | Runs, not asserted |
verifySlow | Fatal error, process ends | Yes | On | Runs, not asserted | Runs, not asserted | Runs, not asserted |
ensure, ensureMsgf | Log, callstack and non-fatal report, once per call site; execution continues | Yes | On | On | Returns the value, reports nothing | Returns the value, reports nothing |
ensureAlways, ensureAlwaysMsgf | Same, on every failure | Yes | On | On | Returns the value, reports nothing | Returns the value, reports nothing |
Three things to take from it. Only the check family removes its expression. verify and ensure always evaluate theirs, in every configuration. And Test behaves like Shipping here, which surprises teams who profile on Test builds and expect asserts.
What switches them on and off
Three preprocessor switches in Misc/Build.h control everything. DO_CHECK gates check and verify, DO_GUARD_SLOW gates the Slow variants, and DO_ENSURE gates ensure. Debug sets all three. Development sets DO_CHECK and DO_ENSURE. Any build with the editor compiled in has checks and ensures on. Test and Shipping take DO_CHECK from USE_CHECKS_IN_SHIPPING and DO_ENSURE from USE_ENSURES_IN_SHIPPING, and both default to 0. DebugGame counts as Development for this purpose, so checkSlow is off there too.
The supported way to flip the first one is a property in your target file:
// Source/MyGame.Target.cs
public MyGameTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.Latest;
bUseChecksInShipping = true; // checks (and, by default, ensures) in Test and Shipping
}
There is no matching bUseEnsuresInShipping in the target rules. USE_ENSURES_IN_SHIPPING defaults to whatever USE_CHECKS_IN_SHIPPING is, so turning checks on turns ensures on with them unless you define the ensure macro yourself. The exact defaults have moved between engine versions, and Epic’s own asserts page lists Test differently from the header, so when it matters, read Build.h in the engine you ship with.
One practical limit: the setting changes how engine code is compiled. With an engine installed from the Epic Games Launcher, UnrealBuildTool objects that your target modifies a setting shared with the prebuilt engine. Getting checks into engine code as well as your own needs an engine built from source.
check: for invariants
A check states something that must be true for the code after it to make sense. When it is false there is no sensible way to continue, so the engine stops.
void UInventory::RemoveAt(int32 Index)
{
checkf(Items.IsValidIndex(Index), TEXT("RemoveAt(%d) with %d items"), Index, Items.Num());
Items.RemoveAt(Index);
}
What you see when it fails, in the crash reporter and the log:
Assertion failed: Items.IsValidIndex(Index) [File:D:\Projects\MyGame\Source\MyGame\Private\Inventory.cpp] [Line: 57]
RemoveAt(4) with 3 items
With a debugger attached, execution breaks on the line instead. The message in checkf costs nothing until the condition fails, so write the values that will let you diagnose it without a repro. The engine uses the same mechanism: the bounds check behind “Assertion failed: (Index >= 0) & (Index < ArrayNum)” and the thread check behind “Assertion failed: IsInGameThread()” are both checks, and both are absent from a default Shipping build, where the same mistake becomes memory corruption or a crash somewhere less helpful.
checkSlow is for conditions too expensive for Development, such as walking a container to validate it. It exists only in Debug builds.
verify: when the expression must run
The classic assert bug in Unreal is real work placed inside a check:
// Broken: in Shipping the whole line is removed, so the save is never loaded
check(LoadSaveGame(SlotName));
// Also broken: the pop and the increment disappear in Shipping
check(Stack.Pop() == Expected);
check(++RetryCount < MaxRetries);
Everything works in the editor and in Development builds, and the packaged Shipping game behaves differently with no error anywhere. verify exists for exactly this. It asserts like check where checks are on, and where they are off it still evaluates the expression and discards the result:
// The call always runs. The result is only asserted where checks are enabled.
verify(LoadSaveGame(SlotName));
That fixes the disappearing call, but look at what Shipping does with a failure: nothing. If a failed load is something that can happen on a player’s machine, neither macro is the right tool. Handle the result:
if (!LoadSaveGame(SlotName))
{
UE_LOG(LogMyGame, Warning, TEXT("Could not load slot %s, starting a new game"), *SlotName);
StartNewGame();
}
A rule that prevents the bug: the argument of check should be something you could delete without changing behaviour. If it calls a non-const function, assigns, increments or pops, it belongs outside the macro or inside verify.
ensure: for surprises you can survive
ensure is an expression, not a statement. It returns the condition, so it sits inside an if and gives you a report and a recovery path in one line:
void AMyCharacter::Fire()
{
if (!ensureMsgf(IsValid(Weapon), TEXT("Fire called with no weapon on %s"), *GetName()))
{
return;
}
Weapon->Fire();
}
When the condition is false in a build with ensures on, the engine logs the failure with a callstack and hands a non-fatal report to the crash reporter, then carries on:
LogOutputDevice: Error: === Handled ensure: ===
LogOutputDevice: Error: Ensure condition failed: IsValid(Weapon) [File:D:\Projects\MyGame\Source\MyGame\Private\MyCharacter.cpp] [Line: 88]
LogOutputDevice: Error: Fire called with no weapon on BP_Player_C_0
LogOutputDevice: Error: Stack:
LogOutputDevice: Error: [Callstack] 0x00007ff6c1a2b3c4 MyGame.exe!AMyCharacter::Fire() [D:\Projects\MyGame\Source\MyGame\Private\MyCharacter.cpp:88]
Details that change how you use it:
- It fires once per call site per run. The second failure at the same line is silent, which keeps a per-frame failure from flooding the log. It also means a count of ensure reports is a count of sessions that hit the problem, not of occurrences.
ensureAlwaysreports every time. - The first failure is slow. Capturing and symbolicating the stack and writing the report happens on the calling thread and can stall it for a noticeable fraction of a second. One hitch per call site is acceptable.
ensureAlwaysin a function that runs every frame is not. - With a debugger attached it breaks, like a breakpoint, and you can continue.
- In Shipping it is a plain Boolean test. The expression is evaluated and returned, so the early return above still protects the player. No log, no report.
- Two console variables adjust it:
core.EnsureAlwaysEnabledset to false makesensureAlwaysbehave likeensure, andcore.EnsuresAreErrorschooses whether failures are logged as errors or warnings.
Do not use ensure for things that are expected to happen: bad input from the network, a missing optional asset, a player doing something odd. Those are ordinary branches. An ensure that fires routinely teaches the team to ignore ensures. What to do with one that has fired is covered in “Ensure condition failed”.
The control-flow checks
Four macros assert on reaching a line instead of on a condition. All follow DO_CHECK.
const TCHAR* ToString(EDoorState State)
{
switch (State)
{
case EDoorState::Open: return TEXT("Open");
case EDoorState::Closed: return TEXT("Closed");
}
checkNoEntry(); // a new enum value was added and not handled
return TEXT("");
}
void UMySubsystem::InitOnce()
{
checkNoReentry(); // fails the second time this line runs
}
void UGraphWalker::Visit(FNode& Node)
{
checkNoRecursion(); // fails if Visit is entered again before it returns
}
void UWeaponBase::Fire()
{
unimplemented(); // subclasses must override; calling the base is a bug
}
Because they vanish in Shipping, always follow checkNoEntry() with a safe return, as above.
Which one to use
- Would continuing corrupt state or crash anyway a few lines later? Use
checkorcheckf. An index out of range, a null that the next line dereferences unconditionally, a function called on the wrong thread. - Does the expression do something the program needs? Use
verify, or better, pull the call out, store the result andcheckthe result. - Is it a bug, but one you can step around? Use
ensureMsgfinside anifand return, skip or substitute a default. Most gameplay code belongs here: a missing component, a null target, an unexpected state. - Can it happen in normal operation? Use none of them. Branch, and log with
UE_LOGif it is worth knowing about. - Must it stop the game even in Shipping? Asserts will not do that by default.
UE_LOG(LogMyGame, Fatal, TEXT("…"))is a fatal error in every configuration, including builds with logging compiled out.
Should you enable checks in Shipping
Epic’s documentation says projects should ship with USE_CHECKS_IN_SHIPPING at its default of 0, and the reasons are sound. The engine contains a very large number of checks, many on hot paths such as array indexing, and each one is a branch plus the cost of its expression. A failed check also turns a state the player might have survived into a guaranteed crash.
What you gain by turning them on is diagnosis: a failed invariant stops at the line that detected it, with your message, instead of surfacing later as an access violation in unrelated code. A middle path works for most teams. Ship Shipping with the defaults. Give playtesters, QA and closed beta players a Development build, or a Test build with bUseChecksInShipping set, so asserts and ensures are live where the stakes are low. And for the few invariants where continuing would damage a save file or a player’s progress, use the explicit Fatal log from the list above so the behaviour does not depend on build flags.
Blueprint has no asserts
There is no check or ensure node. Blueprint’s equivalents are weaker: Print String, which is stripped from Shipping, the Is Valid nodes, and the runtime errors the virtual machine raises itself, of which “Accessed None trying to read property” is the one every project meets. Those errors skip the node and continue, much like a silent ensure. If a C++ function is called from Blueprint with arguments that must be valid, put an ensureMsgf at the top of it: the designer gets a log line and a callstack that includes the script stack instead of a quiet no-op.
What reaches Bugnet
The Bugnet Unreal SDK binds to FCoreDelegates::OnHandleSystemError, so a failed check or verify, or any other fatal error, is filed as a report with the engine’s error text (the Assertion failed: … [File:…] [Line: …] line), a stack trace and the recent log lines, alongside OS, CPU, GPU, RAM and game version. It also reports ensure failures: the first one in a run is filed with its stack and the log lines that carry the expression, file and line. Ensure reports share one title, so they stack as a single entry; read the log lines to tell call sites apart. The limits follow from the table at the top. In a default Shipping build neither macro fires, so there is nothing to report, and the SDK does not turn a native crash into a symbolicated stack. Setup is in the SDK docs.
Related guides
- How to Fix “Ensure condition failed” in Unreal Engine
- How to Fix “Assertion failed: IsInGameThread” in Unreal Engine
- How to Fix “Assertion failed: (Index >= 0) & (Index < ArrayNum)” in Unreal Engine
- How to Fix “Accessed None trying to read property” in Unreal Engine Blueprints
- Crash Reporting for Unreal Engine Shipping Builds
Frequently asked questions
What is the difference between check and ensure in Unreal Engine?
check is fatal: when its condition is false the engine logs Assertion failed and the process ends. ensure is not fatal: it logs the failure with a callstack, sends a non-fatal report once per call site, returns false and lets the code continue. Both are inactive in a default Shipping build.
Is check compiled out of Shipping builds?
Yes. In Test and Shipping builds check and checkf expand to nothing unless you set bUseChecksInShipping in your Target.cs. The expression inside is not evaluated at all, so any function call or assignment written inside a check disappears from the shipped game.
When should I use verify instead of check?
Use verify when the expression has a side effect the program depends on, such as a call that loads data or registers something. verify still evaluates the expression in Shipping and only skips the assert. If the failure can really happen for players, handle the result with an if instead.
Does ensure work in Shipping builds?
The expression still runs and its value is still returned, so code like if ensure and return keeps working. What is removed by default is the reporting: no log line, no callstack and no crash reporter upload. Enabling checks in Shipping enables ensure reporting too, by default.
Why did my game hitch when an ensure fired?
The first failure at each call site captures and symbolicates a callstack and writes a report on the calling thread, which can take a noticeable fraction of a second. Later failures at the same line are silent. Avoid ensureAlways in code that runs every frame.
Never put work inside check. If deleting the expression would change what the game does, it is gone from your Shipping build.