FVector::Normalize() compiles incorrectly?

Hi!

I have the following code:

FVector TestVector(
		0.f,
		100.f - FMath::RandRange(-10.f, 10.f),
		0.f
	);

	UE_LOG(Log, Error, L"TestVector: %.2f, %.2f, %.2f", TestVector.X, TestVector.Y, TestVector.Z);

	TestVector.Normalize();

	UE_LOG(Log, Error, L"TestVector: %.2f, %.2f, %.2f", TestVector.X, TestVector.Y, TestVector.Z);

	TestVector *= 10.f;

	UE_LOG(Log, Error, L"TestVector: %.2f, %.2f, %.2f", TestVector.X, TestVector.Y, TestVector.Z);

In DEBUG mode this outputs the following to the log:

TestVector: 0.00, 109.68, 0.00
TestVector: 0.00, 1.00, 0.00
TestVector: 0.00, 10.00, 0.00

The last line TestVector: 0.00, 10.00, 0.00 is the expected result.
However, when I compile the exact same code in DEVELOPMENT mode the output to the log is:

TestVector: 0.00, 104.32, 0.00
TestVector: 0.00, 0.00, 0.00
TestVector: 0.00, 0.00, 0.00

The result is incorrect, the normalization failed. If I replace TestVector.Normalize(); with TestVector = TestVector.GetSafeNormal(); the result become correct again, both in DEBUG and DEVELOPMENT mode.

I don’t really understand why this is happening, blaming the compiler is normally a mistake but this looks indeed very strange? Especially since the methods should be marked with FORCEINLINE.

Specs: Windows 10, Visual studio 16.3.5, UE 4.22.3 no plugins.

Any ideas what might cause this? my workaround for now is to ban usage of Normalize and stick to only using GetSafeNormal. Any help would be appreciated!

EDIT: I have the same problem with UE 4.23.1

Hey, yes it’s a known bug, microsoft team has a fix on the way, but for now i suggest you to use older compilation toolchain :

here is a copy past of the workarround :

Workarround only : Install 14.22 toolchain in vs installer and force it in UE by setting BuildConfiguration.xml

Check your exact version in folder "Microsoft Visual Studio\2019\VC\Tools\MSVC" in your visual studio install path ( see in vs installer )

<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">;

	<WindowsPlatform>
		<CompilerVersion>14.22.27905</CompilerVersion>
	</WindowsPlatform>
</Configuration>
infos: https://docs.unrealengine.com/en-US/Programming/BuildTools/UnrealBuildTool/BuildConfiguration/index.html

i personnaly used the path :AppData\Roaming\Unreal Engine\UnrealBuildTool for the file

Thank you so much! That fixed and explained my problems!