-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Describe the bug
It's hard to describe this bug, it seems to depend on a lot of things. I cannot build you guys the perfect test case, sorry, I only try to report something, that had cost me some hours and nerves..., but anyway you can download the whole code and test with it.
I am exclusively using C++20 modules, with /std:c++latest and I tested it on Visual Studio 2022 17.7.2 and 17.8.0 Preview 1.0, but the error occurred since 17.5.x as I remember.
This code is marked as the problem:
Note: Full Source: https://github.com/OmniVortexStudios/ultra/blob/master/Source/Library/Ultra/Utility/DateTime.ixx
inline string GetTimeStamp() const { return GetTicks(); }
inline string GetTicks (const string_view &format = "{:%Y-%m-%dT%H:%M:%S}") const {
auto args = std::make_format_args(SystemClock::now());
try {
return std::vformat(format, args);
} catch (const std::exception &ex) {
return ex.what();
}
}
It is called over:
Note: Full Source: https://github.com/OmniVortexStudios/ultra/blob/master/Source/Library/Ultra/Core/Logger.ixx
struct LogRecord {
LogRecord(const char *format, const LogLevel &level = LogLevel::Default, const string ×tamp = apptime.GetTimeStamp(), const SourceLocation &location = SourceLocation::Current()):
Format(format),
Level(level),
Location(location),
Timestamp(timestamp) {
}
const char *Format;
mutable LogLevel Level;
SourceLocation Location;
string Timestamp;
};
In some, not all modules, the compile time error was triggered:
Note:
- https://github.com/OmniVortexStudios/ultra/blob/master/Source/Library/Ultra/Engine/Scene/Scene.ixx
- https://github.com/OmniVortexStudios/ultra/blob/master/Source/Library/Ultra/Platform/Engine/OpenGL/GLRenderDevice.cxx
- https://github.com/OmniVortexStudios/ultra/blob/master/Source/Library/Ultra/Platform/GFX/Vulkan/VKDevice.cxx
- https://github.com/OmniVortexStudios/ultra/blob/master/Source/Library/Ultra/Platform/GFX/Vulkan/VKInstance.cxx
- https://github.com/OmniVortexStudios/ultra/blob/master/Source/Library/Ultra/Platform/GFX/Vulkan/VKVKSwapChainLegacy.cxx
- https://github.com/OmniVortexStudios/ultra/blob/master/Source/Library/Ultra/Platform/UI/WinAPI/WinWindow.cxx
when using my logger...
LogError("Error"); // Dosn't realy matter what of it, as the timestamp is created over the function call
The issue is simple for you guys, I think, I get the following errors:
/// type_traits(1344,53): error C2794: 'type': is not a member of any direct or indirect base class of 'std::common_type<_Rep1,_Rep2>'
/// with
/// [
/// _Rep1 = __int64,
/// _Rep2 = __int64
/// ]
/// __msvc_chrono.hpp(268,35): error C2938: 'std::common_type_t' : Failed to specialize alias template
/// __msvc_chrono.hpp(268,56): error C2752: 'std::common_type<_Rep1,_Rep2>': more than one partial specialization matches the template argument list
/// with
/// [
/// _Rep1 = __int64,
/// _Rep2 = __int64
/// ]
/// __msvc_chrono.hpp(113,54): error C2955: 'std::chrono::duration': use of class template requires template argument list
/// __msvc_chrono.hpp(118,54): error C2955: 'std::chrono::duration': use of class template requires template argument list
///
Workaround
I found out that a simple #include <chrono> in the affected modules fixed the error, so I think it has something to do with Microsoft's STL implementation in combination with C++20 Modules.
I couldn't track the issue further, sorry, it is far beyond my knowledge.
Expected behavior
std::chrono::time_pointstd::chrono::system_clock;
--> Should work across module boundaries
Hopefully that makes sense...
STL version
- Option 1: Visual Studio version
Microsoft Visual Studio Community 2022 Version 17.7.2 Microsoft Visual Studio Community 2022 Version 17.8.0 Preview 1.0 - Option 2: git commit hash
- run prepare.bat -silent
- set Test as start project
- uncomment the
#include <chrono>in one of the affected modules (also visible in the commit log)https://github.com/OmniVortexStudios/ultra/commit/e3b0358b785efbb46cdd5ab56a42658be2362f3c
Additional context
You can find the affected modules with my marked comment:
/// @brief Hack: This is an nasty fix for Microsoft's STL implementation
Sorry, if i couldn't help you further.