I could not reproduce the issue with VS2019 16.11.5 in debug and release builds for both x86 and x64. I started with an Empty project and added a source file into which I pasted the posted code. The only changes that I made to project options across all configurations/platforms were to set /std:c++latest and /experimental:module.
Each build completed successfully although warning messages were issued by the compiler.
x86 - Debug build output -
Build started...
1>------ Build started: Project: ModuleTest, Configuration: Debug Win32 ------
1>Source.cpp
1>C:\Users\RLWA32\source\repos\ModuleTest\ModuleTest\Source.cpp(1,16): warning C5050: Possible incompatible environment while importing module 'std.core': _GUARDOVERFLOW_CRT_ALLOCATORS=1 is defined in current command line and not in module command line
1>C:\Users\RLWA32\source\repos\ModuleTest\ModuleTest\Source.cpp(1,16): warning C5050: Possible incompatible environment while importing module 'std.core': _DEBUG is defined in current command line and not in module command line
1>C:\Users\RLWA32\source\repos\ModuleTest\ModuleTest\Source.cpp(1,16): warning C5050: Possible incompatible environment while importing module 'std.core': _M_FP_PRECISE is defined in current command line and not in module command line
1> Creating library C:\Users\RLWA32\source\repos\ModuleTest\Debug\ModuleTest.lib and object C:\Users\RLWA32\source\repos\ModuleTest\Debug\ModuleTest.exp
1>ModuleTest.vcxproj -> C:\Users\RLWA32\source\repos\ModuleTest\Debug\ModuleTest.exe
1>Done building project "ModuleTest.vcxproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
x86 Debug Command line -
/JMC /experimental:module /permissive- /ifcOutput "Debug\" /GS /analyze- /W3 /Zc:wchar_t /ZI /Gm- /Od /sdl /Fd"Debug\vc142.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /std:c++latest /FC /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Fp"Debug\ModuleTest.pch" /diagnostics:column
x86 Release Build Output
Build started...
1>------ Build started: Project: ModuleTest, Configuration: Release Win32 ------
1>Source.cpp
1>C:\Users\RLWA32\source\repos\ModuleTest\ModuleTest\Source.cpp(1,16): warning C5050: Possible incompatible environment while importing module 'std.core': _GUARDOVERFLOW_CRT_ALLOCATORS=1 is defined in current command line and not in module command line
1>C:\Users\RLWA32\source\repos\ModuleTest\ModuleTest\Source.cpp(1,16): warning C5050: Possible incompatible environment while importing module 'std.core': _M_FP_PRECISE is defined in current command line and not in module command line
1> Creating library C:\Users\RLWA32\source\repos\ModuleTest\Release\ModuleTest.lib and object C:\Users\RLWA32\source\repos\ModuleTest\Release\ModuleTest.exp
1>Generating code
1>Previous IPDB not found, fall back to full compilation.
1>All 6 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
1>Finished generating code
1>ModuleTest.vcxproj -> C:\Users\RLWA32\source\repos\ModuleTest\Release\ModuleTest.exe
1>Done building project "ModuleTest.vcxproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
x86 Release Command line -
/experimental:module /permissive- /ifcOutput "Release\" /GS /GL /analyze- /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Fd"Release\vc142.pdb" /Zc:inline /fp:precise /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MD /std:c++latest /FC /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\ModuleTest.pch" /diagnostics:column