How to access a TStaticBitArray

Hello

How do I correctly access a TStaticBitArray?

I’m currently wondering why my access to a StaticBitArray always returns 1.

UDummy* d = GEngine->GetEngineSubsystem<UDummy>();

d->Ids[1003]; //return 1 => true

d->Ids[1002]; //return 1 => true

d->Ids[1004] == 1 //return 1 => true

But if I’m printing the BitArray with ToString() it returns only zeros (d->Ids.ToString() => 000...0000)

What am I doing wrong?

What am I missing?

Why is the value I print different from the one I’m comparing it to?

Regards

Gerrit

`class EXAMPLIE_API UDummy : public UEngineSubsystem
{

TStaticBitArray<1000000> Ids;

void Init();

}

void UDummy::Init()
{
Ids= TStaticBitArray<1000000>();
}`*

Steps to Reproduce

Hi there, with the provided sample code I can’t reproduce the problem in UE 5.5.4.

When I access the static bit array’s elements, they all have their original value of 0:

`// MyActor has the TStaticBitArray member.
void AMyActor::BeginPlay()
{
Super::BeginPlay();

Ids = TStaticBitArray<1000000>();
TStaticBitReference BitRef = Ids[1003];
bool bIsBitSet = BitRef.operator bool();
bool bIsBitSet2 = Ids[1003] == 1;

// Prints 0 0 0
UE_LOG(LogTemp, Warning, TEXT(“Bit value: %d %d %d”), int32(Ids[1003]), bIsBitSet, bIsBitSet2);
}`Can you double check your project if any step is missing to reproduce the issue or provide a small repro project?