Hi all,
twiddle’s diagnosis of the problem is correct in that it’s an alignment issue. The compiler is copying FQuat::Identity into an unaligned temporary on the stack (because you’re passing by value) using movups, then the code inside ConvertToUe4Rotation is reading it using movaps.
This appears to be a problem with DLL-imported statics, as a module-local static (i.e. not DLL-imported) doesn’t exhibit this problem. Other ways to work around the problem:
- Pass the FQuat by reference, not by value, avoiding the temporary.
- Put the code in a function and call the function instead.
- Add a static FQuat::GetIdentity() function are call that instead of referencing the static member directly.
We believe it’s a VC code generation problem and are trying to reproduce a minimal example in a standalone C++ project to report to Microsoft’s compile team. For now, we suggest passing by reference instead of by value, as passing aligned types by value has issues on 32-bit platforms anyway.
Steve