Code optimization produces strange bug

Hi,

i have a really strange bug regarding code optimization.
I’m using the FMOD Plugin and got an error about vectors not being unit vectors, so i did some debugging.
The original code is just the first line (the rest is ugly debugging code):

290864-code1.png

It should just return the forward vector as unit vector. My debugging code contains some other ways to do it.
If I have the code optimazation disabled (using OptimizeCode = CodeOptimization.Never in the build.cs) i get the following result:

290865-noopt.png

Just how it should be. However, if i remove the line and leave the optimization enabled i get this:

290866-opt.png

The results become quite absurd. The only correct one is ‘Forward3a’, so the only one that does not call the function “GetSafeNormal”. I dont have any problems like this in my main game module just in this plugin. Anyone else experienced something like this?

Hi, i suspect you are using vs2019.3, 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: Build Configuration | Unreal Engine Documentation

related issue:

Thank you for the fast answer. The links explain a lot.
Strange i did not find that with the search. Was using the wrong keywords i guess.

Btw current state: “If everything flows as planned, the fix should be in the next 16.4 Preview release”