forked from microsoft/vcpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mongo-cxx-driver] Patch std::atomic P0883 changes
Previously submitted as mongodb/mongo-cxx-driver#654
- Loading branch information
1 parent
b271aef
commit f1d5675
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
From e1a92d8bf8f07abc89350a956819b78df05bc4fe Mon Sep 17 00:00:00 2001 | ||
From: Billy Robert O'Neal III <bion@microsoft.com> | ||
Date: Mon, 25 May 2020 20:47:58 -0700 | ||
Subject: [PATCH] Disable trivially_constructible test for atomic on MSVC++. | ||
|
||
MSVC++ implements P0883 unconditionally, which changes the rules for std::atomic. It removes atomic's trivial constructor, and makes the default constructor value initialize the T. | ||
|
||
Note that Mongo was not following the C++11 rules, because it used the atomic before calling atomic_init first. MSVC++ never implemented the C++11 rules and previously default initialized the T. | ||
|
||
All versions of MSVC++ will provide constant initialization of the guarded value "current_instance". In old versions, atomic didn't implement P0883 due to bugs in the constexpr evaluator; in current versions the constexpr evaluator was fixed and atomic value initializes unconditionally. Therefore, this PR disables the check whenever MSVC++'s standard library is detected. | ||
|
||
See https://github.com/microsoft/STL/issues/661 for further discussion. | ||
--- | ||
src/mongocxx/instance.cpp | 3 ++- | ||
1 file changed, 2 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/src/mongocxx/instance.cpp b/src/mongocxx/instance.cpp | ||
index e67d41ec7..6eb456c65 100644 | ||
--- a/src/mongocxx/instance.cpp | ||
+++ b/src/mongocxx/instance.cpp | ||
@@ -75,7 +75,8 @@ typename std::aligned_storage<sizeof(instance), alignof(instance)>::type sentine | ||
std::atomic<instance*> current_instance{nullptr}; | ||
static_assert(std::is_standard_layout<decltype(current_instance)>::value, | ||
"Must be standard layout"); | ||
-#if (!defined(__GNUC__) || (defined(__clang__) && !defined(__GLIBCXX__))) || (__GNUC__ >= 5) | ||
+#if (!defined(_MSVC_STL_VERSION)) \ | ||
+ && ((!defined(__GNUC__) || (defined(__clang__) && !defined(__GLIBCXX__))) || (__GNUC__ >= 5)) | ||
static_assert(std::is_trivially_constructible<decltype(current_instance)>::value, | ||
"Must be trivially constructible"); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters