UnrealEngine failed to build due to error C4800: Implicit conversion from 'int32' to bool. Possible information loss on x64 with MSVC

Environment:
VS 2017 + Windows Server 2016

Issue description:
UnrealEngine failed to build due to error C4800: ‘‘Implicit conversion from ‘int32’ to bool. Possible information loss’’ on x64 with MSVC. This issue can be reproduced on commit 0697cef on UE Github Master branch.Could you please help take a look at this? Thank you!

Steps to Reproduce:

  1. git clone https://github.com/EpicGames/UnrealEngine D:\UnrealEngine\src
  2. Open a VS 2017 x64 command prompt and browse to D:\UnrealEngine
  3. cd src
  4. Setup.bat
  5. GenerateProjectFiles.bat
  6. .\Engine\Build\BatchFiles\Rebuild.bat UE4Editor Win64 Development -waitmutex -verbose

link text

Actual result:
D:\UnrealEngine\src\Engine\Source\Runtime\Renderer\Private\DeferredShadingRenderer.cpp(945): error C4800: Implicit conversion from ‘int32’ to bool. Possible information loss
D:\UnrealEngine\src\Engine\Source\Runtime\Renderer\Private\RayTracing\RayTracingGlobalIllumination.cpp(345): error C4800: Implicit conversion from ‘int32’ to bool. Possible information loss
D:\UnrealEngine\src\Engine\Source\Runtime\Renderer\Private\RayTracing\RayTracingReflections.cpp(258): error C4800: Implicit conversion from ‘T’ to bool. Possible information loss
with
[
T=int32
]
D:\UnrealEngine\src\Engine\Source\Runtime\Renderer\Private\RayTracing\RayTracingReflections.cpp(258): note: consider using explicit cast or comparison to 0 to avoid this warning
D:\UnrealEngine\src\Engine\Source\Runtime\Renderer\Private\RayTracing\RayTracingReflections.cpp(258): note: see declaration of ‘T’
D:\UnrealEngine\src\Engine\Source\Editor\MeshPaintMode\Private\PaintModeSettingsCustomization.cpp(374): error C4800: Implicit conversion from ‘int32’ to bool. Possible information loss
D:\UnrealEngine\src\Engine\Plugins\FX\Niagara\Source\NiagaraEditor\Private\NiagaraCompiler.cpp(620): error C4800: Implicit conversion from ‘int32’ to bool. Possible information loss
D:\UnrealEngine\src\Engine\Plugins\FX\Niagara\Source\NiagaraEditor\Private\NiagaraCompiler.cpp(771): error C4800: Implicit conversion from ‘int32’ to bool. Possible information loss

Hello,

We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.

https://epicsupport.force.com/unrealengine/s/

Thanks

Thanks for your reply!

I’ve reported as you provided new link: Unreal Engine Community . But only show your case has been submitted. No return ticket number, we can not find this issue ticket.

Thanks,

Did anything change regarding this issue? It still persists in the 4.22 branch!

I installed vs 2019 and get the same problem! I can not compile the engine!

I don’t see this on the issues page either. I would like to up-vote because I have the same problem building with 4.22 release and vs2019. I did get a successful build at first when I opened the version 15 (2017) sln file in vs2019 because it seem to still use the vs2017 toolchain. But when I “GeneratedProjectFiles -2019” to get the correct sln file for vs2019 which uses the 2019 toolchain I get the error.

I am using 4.22 Release, Visual Studio 2019 and Windows10 and got the same error. I see you are using a different Environment, but this may help until Epic Devs can help/fix. I found a link to a tutorial that solved the errors for me.
link text
When I added the two arguments to the VCToolChain.cs file after line 484 I got it to build without errors.

Arguments.Add("/wd4800");
Arguments.Add("/wd5038");

Since your in a different environment, I’m not sure if the this will help or if the code line will be in the same location.
Also beware that the quote marks in the tutorial need to be corrected to straight quotes " " because they are curly quotes “ ” , if you copy/paste them from the webpage into the VCToolChain.cs file you may get an error.

The version of the MSVS 4.20 does not work, the return is up to 4.16 problems.

I’m going to post Sarlack’s comment as an answer because I’m sure that is the correct answer. Essentially, you have to suppress these compiler warnings by going into the VCToolChain.cs file located at the file path, Engine\Source\Programs\UnrealBuildTool\Platform\Windows. And after line 484, just add these two lines,

Arguments.Add("/wd4800");

Arguments.Add("/wd5038");

c4800 is the code for the compiler warning,

Implicit conversion from ‘type’ to bool. Possible information loss

c5038 is the code for the compiler warning,

data member ‘member1’ will be initialized after data member ‘member2’ data member ‘member’ will be initialized after base class ‘base_class’

UPDATE

This will be resolved in 4.22.1. https://github.com/EpicGames/UnrealEngine/pull/5752

Check my PR on Feb, 22

https://github.com/EpicGames/UnrealEngine/pull/5572

I fixed it when I got vs 2019 preview 3, and the PR is merged by epic in 4.22.1 already on Apr, 5.