Getting "error C4756: overflow in constant arithmetic" while building Unreal 5.4.2 from source code

(Please also read the 2nd message, most probably it is related to installing Windows SDK)
I was able to build Unreal engine from source code previously. After some time, I tried again with Unreal 5.4.2 version with VS 2022. It compiled almost all of the files, however I received several errors saying:
“error C4756: overflow in constant arithmetic”

[1/387] Compile [x64] Module.AudioSynesthesiaCore.cpp
PATH\Engine\Plugins\Runtime\AudioSynesthesia\Source\AudioSynesthesiaCore\Private\PeakPicker.cpp(17) : error C4756: overflow in constant arithmetic
   while compiling Audio::FPeakPicker::FPeakPicker
[2/387] Compile [x64] Module.RenderCore.2.cpp
PATH\Engine\Source\Runtime\RenderCore\Private\RenderGraphPrivate.cpp(196) : error C4756: overflow in constant arithmetic
   while compiling GetClobberValue
[3/387] Compile [x64] Module.LiveLink.cpp
PATH\Engine\Plugins\Animation\LiveLink\Source\LiveLink\Private\LiveLinkClient.cpp(1728) : error C4756: overflow in constant arithmetic
   while compiling FLiveLinkClient_Base_DEPRECATED::PushSubjectData
[4/387] Compile [x64] Module.PoseSearch.3.cpp
PATH\Engine\Plugins\Animation\PoseSearch\Source\Runtime\Private\PoseSearchLibrary.cpp(134) : error C4756: overflow in constant arithmetic
   while compiling FMotionMatchingState::Reset

When I check the source code, I see it is related to macro definition of INFINITY and storing that value within float typed variables.

https://github.com/EpicGames/UnrealEngine/blob/c830445187784f1269f43b56f095493a27d5a636/Engine/Plugins/Animation/LiveLink/Source/LiveLink/Private/LiveLinkClient.cpp#L1728

Settings.MeanDelta = FMath::Clamp(Settings.MeanDelta, 1e-6f, INFINITY); (PieakPicker.cpp, line 17)

https://github.com/EpicGames/UnrealEngine/blob/c830445187784f1269f43b56f095493a27d5a636/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp#L196

Here is how INFINITY is defined in corecrt_math.h

#ifndef _HUGE_ENUF
    #define _HUGE_ENUF  1e+300  // _HUGE_ENUF*_HUGE_ENUF must overflow
#endif

#define INFINITY   ((float)(_HUGE_ENUF * _HUGE_ENUF))

My build process is like that:

./GenerateProjectFiles.bat -2022

          ./Engine/Build/BatchFiles/RunUAT.bat BuildGraph     `
            -script="Engine/Build/InstalledEngineBuild.xml" `
            -target="Make Installed Build Win64"            `
            -set:HostPlatformOnly=true                        `
            -set:GameConfigurations=""                        `
            -set:WithFullDebugInfo=false                      `
            -set:WithDDC=false       			      `
            -set:SignExecutables=false

I was able to compile like that some times ago, but unfortunately not this time.

I want to learn why I got these errors and what is the solution?

Thanks.

2 Likes

I have additional feedback. I have another build pipeline which was working fine but it also started giving errors…

Recently I installed Windows SDK - Windows app development | Microsoft Developer version 10.0.26100.1 because Unreal Build process was complaining about pdbcopy.exe being missing and it guided me to install Windows 10 SDK.

After installing Windows 10 SDK 10.0.26100.1 from the link above, my builds started giving error.

1 Like

same issue here

Same stuff here as well. I would also like to know a solution to this.

1 Like

Hi.
As I mentioned in the first 2 messages, my problem was related to Windows SDK version because INFINITY is defined in the headers coming by SDK package. Either there is a problem with the newest SDK version or we installed an incorrect version of the SDK (like Windows 11 SDK to Windows 10 SDK, just speculating)

The solution for me is to Uninstall the most recent version (10.0.26100.1) and installing “Windows SDK for Windows 11 (10.0.22621.755)”

The SDK archive can be found in this page: Windows SDK and emulator archive | Microsoft Developer

3 Likes

Same here, 5.4.2 with latest vs2022 17.10.3. I’ve ticked both win 11 sdk 10.0.22621.0 and 10.0.26100.0 in the vs installer, hence lots of C4756.

Thanks to @balikamca Untick 10.0.26100.0 fixed the issue.

1 Like

Before remove 26100(the win11 sdk for 24H2 later this year), I tried replace INFINITY macro with both std::numeric_limits::infinity() and it’s ultimate calling builtin function of __builtin_huge_valf(), they both worked.

4 Likes

Thanks for the advice, it works for me by replacing for each error (4 or 5) INFINITY with std::numeric_limits<float>::infinity()

3 Likes

I’m still getting the error on my project, unfortunately.

Not only that, but I removed and reinstalled VS 2022 and my UE 5.2 github repository, then attempted to build and have the same error.

The error occurs building UE with VS and building my project with UGS.

ubt> [5/184] Compile [x64] Module.AudioSynesthesiaCore.cpp
ubt> D:\p4\lunacy\main\UnrealEngine\Engine\Plugins\Runtime\AudioSynesthesia\Source\AudioSynesthesiaCore\Private\PeakPicker.cpp(17) : error C4756: overflow in constant arithmetic
ubt> [6/184] Link [x64] UnrealEditor-AudioSynesthesiaCore.dll cancelled
ubt> [7/184] Compile [x64] Module.RenderCore.2_of_5.cpp
ubt> D:\p4\lunacy\main\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderGraphPrivate.cpp(193) : error C4756: overflow in constant arithmetic

I followed this as closely as possible, though I’m using the Windows 11 SDK our team uses and the UWP setup is different now.

image

My settings match those of our Engineer, which match those of the 5.2 setup article, except for that W11 sdk.

I’m getting the same error when I build from the ue5-main branch. Downgrading the Windows SDK to 10.0.18362 solves the problem for me.

This SDK version is mentioned in the setup document, under section " C++ Tools" (link is posted by deliverator above). Guess that’s the version most Epic developers are using?

I have previously installed the newest SDK (10.0.26100.0), as it is suggested by Visual Studio when I open the UE5 solution. Turns out I should just ignore that VS popup…

Hope this helps.

3 Likes

It works for me too.

Getting the same issue, I’ve reinstalled VS and deleted the sdk from my system and downgraded still no luck

Uninstalling the SDK is not enough, you also have to regenerate your solution file.

I uninstalled 10.0.26100.0 and left only 10.0.18362.0 installed. Beware that the Include directory does not get deleted when you uninstall 10.0.26100.0, so if you don’t regenerate your solution, the old includes will still be referenced and nothing will appear to have changed.

having the same issue, currently. the usual ■■■■ job by microsoft managing their software updates and sdk version clusterf*ck. they spam update like crazy every week, but probably untested. unreliable. hmm

so i should get rid of those and compile another 3 hours?

will it work? ugh. -_-

For anyone want to digger further, here are the bug / issue links:

C4756 related issues in VS 2022 - Developer Community (visualstudio.com)

And for those of you that have UDN access:
C4756 error in compiling UE5.4.2 source code with latest Win11 SDK 26100 (unrealengine.com)

Also, other than my early workaround of using std::numeric_limits::infinity(), here’s another workaround to let you specify the SDK version, the buildconfiguration way, so you don’t have to uninstall the latest 26100 for Unreal.

<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
	<WindowsPlatform>
		<WindowsSdkVersion>10.0.22621.0</WindowsSdkVersion>
	</WindowsPlatform>
</Configuration>
3 Likes

Hi @Trout_Zhang ,
can you explain better how to configure this?
std::numeric_limits::infinity()

I didn’t quite understand what should be done, I’m having this problem, I’m using Windows 10,

I have all of these installed, I don’t know if I should uninstall any of them.

I’m using Unreal 5.3.2

That helped me too! THANKS!!!

Hi @elik745ie , can you explain in more detail what you did to resolve it?

Thanks!

I had the same problem. (my VS is in Portuguese)

After that, I checked which SDKs I had installed and removed the ones that seemed unnecessary, leaving it like that.

The list to know which SDKs I should use, I found in this manual.

Filter by: platform sdk upgrades
And it will tell you which SDKs are recommended.

After that, I opened VS, and in my project I right-clicked and selected Clean.

After that, I recompiled normally, without any errors.