// of this type gives them access to the private members of time_zone
// and tzdb, without needing them declared in the <chrono> header.
+ // The tzdb_list singleton. This doesn't contain the actual linked list,
+ // but it has member functions that give access to it.
static tzdb_list _S_the_list;
#if USE_ATOMIC_SHARED_PTR
// Implementation of the private constructor used for the singleton object.
constexpr tzdb_list::tzdb_list(nullptr_t) { }
- // The tzdb_list singleton. This doesn't contain the actual linked list,
- // but it has member functions that give access to it.
+#pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
+
+ [[gnu::init_priority(99)]]
constinit tzdb_list tzdb_list::_Node::_S_the_list(nullptr);
- // Shared pointer to the first Node in the list.
+ [[gnu::init_priority(99)]]
constinit tzdb_list::_Node::head_ptr tzdb_list::_Node::_S_head_owner{nullptr};
#if USE_ATOMIC_LIST_HEAD
- // Lock-free access to the first Node in the list.
+ [[gnu::init_priority(99)]]
constinit atomic<tzdb_list::_Node*> tzdb_list::_Node::_S_head_cache{nullptr};
#endif
--- /dev/null
+// { dg-do run { target c++20 } }
+// { dg-require-effective-target tzdb }
+// { dg-require-effective-target cxx11_abi }
+// { dg-require-static-libstdcxx }
+// { dg-additional-options "-static-libstdc++" }
+
+#include <chrono>
+
+struct Global
+{
+ Global()
+ {
+ (void) std::chrono::current_zone(); // initialize tzdb on first use
+ }
+
+ ~Global()
+ {
+ (void) std::chrono::current_zone(); // attempt to use it again on exit
+ }
+
+} global;
+
+int main()
+{
+}