Why is Visual Studio 2013 Express showing wrong variable values

Hello, i created a custom 2D array class based on TArray called TArray2D, so i have something like this:

TArray<TArray<T>> Array;

I have the following function defined:

template <class T>
void TArray2D<T>::Init(uint32 Rows, uint32 Columns, T Value)
{
	Array.Init(Rows);

	for (uint32 Row = 0; Row < Rows; Row++)
		Array[Row].Init(Value, Columns);

	this->Rows = Rows;
	this->Columns = Columns;
}

In my character i have a variable with type TArray2D that is initialized on the constructor with:

MyCustomArray.Init(10, 10, NULL);

When i put a breakpoint on line 4 of the Init function i check the function parameters values and it tells me:

Rows	41646784	unsigned int
Columns	260795136	unsigned int

But when i write them using:

UE_LOG(LogTemp, Warning, TEXT("Array with %d %d"), Rows, Columns);

It shows “Array with 10 10” as it should and then he crashes in the for loop on line 6. Do you know why Visual Studio is giving me incorrect values? This isn’t the first time this has happened, there were other times where he tells the incorrect value.

Did you check the value after the Init function was called? Or did you put the breakpoint on Init and check the value. As it will display some uninitialized value prior to Init actually being called. Placing a breakpoint on a line will stop the execution before than line is called.

I placed the breakpoint on Array.Init(Rows); of the Init function and i check Rows and Columns on Visual Studio and he has those weird values, sinces he’s already inside the function the values should have been set for the parameters.

I can also add “Not showing local variable values when the program is stopped on a breakpoint” to the list of problems i’m having :S

This may be happening because you aren’t building with the correct Solution Configuration in Visual Studio. Try changing it to “DebugGame Editor” and the debugger should show the correct value.

I’ve always used Developer editor and for most cases it works fine, but i’ll try to recompile that way and i’ll let you know. Thnks

I believe that did the trick, the only thing that is left to fix is the crash on the for loop when initializing the sub arrays inside the array, but i will open a new thread about it, thank you.