# Why uninitialized variables get initialized in debug build?

**URL:** <https://forums.unrealengine.com/t/why-uninitialized-variables-get-initialized-in-debug-build/1903831>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, CPP\
**Created:** [June 15, 2024, 6:19am UTC](https://forums.unrealengine.com/t/why-uninitialized-variables-get-initialized-in-debug-build/1903831 "2024-06-15T06:19:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![laggyluk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@laggyluk](https://forums.unrealengine.com/u/laggyluk)\
**Post date:** [June 15, 2024, 6:19am UTC](https://forums.unrealengine.com/t/why-uninitialized-variables-get-initialized-in-debug-build/1903831/1 "2024-06-15T06:19:42Z")

</div>

Recently I had a case (twice) when code was working in debug build but was totally messed up in shipping. The scenario is: make some base class in c++, some vars ‘initialized’ like this instead of constructor (some not at all):

UPROPERTY()  
float someSetting = 1.0f;

UPROPERTY(BlueprintReadOnly)  
bool dirty;

Then extend the actor in bp, everything works in pie and in development build but not in shipping. Why exactly and why does it even compile? I remember 5.0 refused to build if structs didn’t have explicit constructors and I thought it was dumb back then, now I think it’s dumb the other way 😛

---

<div class="post-metadata">

**Author:** ![AlienRenders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlienRenders](https://forums.unrealengine.com/u/AlienRenders)\
**Post date:** [June 15, 2024, 1:16pm UTC](https://forums.unrealengine.com/t/why-uninitialized-variables-get-initialized-in-debug-build/1903831/2 "2024-06-15T13:16:34Z")

</div>

If the UPROPERTY is in an actor (or any UObject), all properties are initialized even in shipping. If that’s not happening for you, then something went wrong somewhere.

Note that this doesn’t apply to structs. Structs do not initialized UPROPERTY at all AFAIK. I think this is why Epic encouraged everyone to start using TObjectPtr because those are managed regardless of where they are located.
