Remove static initializer from mutex.h.
PiperOrigin-RevId: 491915718
Change-Id: I7469601857b5a3506163518d29f49792f3053b34
diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc
index ddd8fb8..c9d7c41 100644
--- a/absl/synchronization/mutex.cc
+++ b/absl/synchronization/mutex.cc
@@ -2787,8 +2787,7 @@
return *(static_cast<bool *>(arg));
}
-Condition::Condition() = default; // null constructor, used for kTrue only
-const Condition Condition::kTrue;
+ABSL_CONST_INIT const Condition Condition::kTrue;
Condition::Condition(bool (*func)(void *), void *arg)
: eval_(&CallVoidPtrFunction),
diff --git a/absl/synchronization/mutex.h b/absl/synchronization/mutex.h
index 779aafa..c6a8510 100644
--- a/absl/synchronization/mutex.h
+++ b/absl/synchronization/mutex.h
@@ -729,7 +729,7 @@
: Condition(obj, static_cast<bool (T::*)() const>(&T::operator())) {}
// A Condition that always returns `true`.
- static const Condition kTrue;
+ ABSL_CONST_INIT static const Condition kTrue;
// Evaluates the condition.
bool Eval() const;
@@ -766,10 +766,10 @@
#endif
// Function with which to evaluate callbacks and/or arguments.
- bool (*eval_)(const Condition*);
+ bool (*eval_)(const Condition*) = nullptr;
// Either an argument for a function call or an object for a method call.
- void *arg_;
+ void *arg_ = nullptr;
// Various functions eval_ can point to:
static bool CallVoidPtrFunction(const Condition*);
@@ -790,7 +790,8 @@
std::memcpy(callback, callback_, sizeof(*callback));
}
- Condition(); // null constructor used only to create kTrue
+ // Used only to create kTrue.
+ constexpr Condition() = default;
};
// -----------------------------------------------------------------------------