There's an issue when assigning a bitfield bool to a native bool in Blueprints. Currently, the engine erroneously treats the memory for a local bool as a uint8 bitfield, which is undefined behavior. Some compilers (eg: clang) can generate optimized code that makes assumptions about the contents of the local bool, which can result in setting booleans to incorrect values.
One potential workaround is to change the lines in UObject::execLetBool of ScriptCore.cpp:
bool NewValue = false; // evaluate the r-value for this expression into Value Stack.Step( Stack.Object, &NewValue );
to
uint8 TempValue = 0; // evaluate the r-value for this expression into Value Stack.Step(Stack.Object, &TempValue); bool NewValue = TempValue != 0;
However, be advised that this is changing one type of undefined behavior for another (ie: you'll have instructions treating the memory for uint8 as a bool), so there could be issues there.
Our fix for this issue will actually introduce correct conversion instructions in the Blueprint compiler to ensure that we handle assigning bitfields to bools.
Note: this repro is not guaranteed to be consistent as it depends on a specific configuration and toolchain.
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-328847 in the post.
0 |
Component | UE - Framework - Blueprint Compiler |
---|---|
Affects Versions | 5.6 |
Target Fix | 5.8 |
Created | Sep 17, 2025 |
---|---|
Updated | Sep 18, 2025 |