Description

TArrayView64 RangeCheck prints the incorrect error messages for values over 32 bit.

Repro Rate: 4/4

Tested this in //UE4/Release-4.27 @ CL#18319896 and the issue did occur there, it is not a regression.

Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:E:\Binary\UE_5.0\Engine\Source\Runtime\Core\Public\Containers\ArrayView.h] [Line: 254] Array index out of bounds: -2 from an array of size -2
Steps to Reproduce
  1. Create a new blank C++ project
  2. Create a new C++ class based on Actor
  3. In 'MyActor.cpp' add the following code below Super::BeginPlay():
    • 	int64 len = (int64)INT_MAX + (int64)INT_MAX;
      	TArray64<int> mainArray;
      	mainArray.AddZeroed(len);
      	TArrayView64<int> arr(mainArray);
      	UE_LOG(LogTemp, Warning, TEXT("ARR LENGTH: % lld"), arr.Num());
      	UE_LOG(LogTemp, Warning, TEXT("last+1 value is %lld"), arr[len]); // Purposefully access an index out of bounds.
    • We're filling TArrayView64 with zeros up to the length of 4294967294 (INT_MAX + INT_MAX)
  1. Recompile the project and place MyActor into the scene.
  2. Play in Editor

Results: Intended assertion occurs with the incorrect index and size of the array (Array index out of bounds: -2 from an array of size -2)
Expected: Intended assertion occurs with the correct values of the index and size of the array (Array index out of bounds: 4294967294 from an array of size 4294967294)

Have Comments or More Details?

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

0
Login to Vote

Fixed
ComponentUE - Foundation - Core
Affects Versions4.275.0
Target Fix5.1
Fix Commit20056439
Main Commit20056439
CreatedApr 29, 2022
ResolvedMay 5, 2022
UpdatedMay 16, 2022