Description

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.

Steps to Reproduce
  1. Download and unzip attached project.
  2. Run editor.
  3. Run PIE.
  4. Validate that "true" is printed.

Note: this repro is not guaranteed to be consistent as it depends on a specific configuration and toolchain.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-328847 in the post.

0
Login to Vote

Unresolved
ComponentUE - Framework - Blueprint Compiler
Affects Versions5.6
Target Fix5.8
CreatedSep 17, 2025
UpdatedSep 18, 2025
View Jira Issue