Now that Marek has implemented constinit (and made it available
pre-C++20 as __constinit) we can use it to enforce constant init for
the globals in src/c++17/memory_resource.cc

Tested x86_64-linux, committed to trunk.

commit 0956a4644f960ad4d537e901d64ec69186ed46b4
Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Mon Sep 2 11:31:34 2019 +0000

    Use __constinit keyword in libstdc++ sources
    
            * src/c++17/memory_resource.cc: Use __constinit keyword.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@275315 
138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/libstdc++-v3/src/c++17/memory_resource.cc 
b/libstdc++-v3/src/c++17/memory_resource.cc
index b6698011f5c..2b64039d280 100644
--- a/libstdc++-v3/src/c++17/memory_resource.cc
+++ b/libstdc++-v3/src/c++17/memory_resource.cc
@@ -85,8 +85,8 @@ namespace pmr
        ~constant_init() { /* do nothing, union member is not destroyed */ }
       };
 
-    constant_init<newdel_res_t> newdel_res{};
-    constant_init<null_res_t> null_res{};
+    __constinit constant_init<newdel_res_t> newdel_res{};
+    __constinit constant_init<null_res_t> null_res{};
 #if ATOMIC_POINTER_LOCK_FREE == 2
     using atomic_mem_res = atomic<memory_resource*>;
 # define _GLIBCXX_ATOMIC_MEM_RES_CAN_BE_CONSTANT_INITIALIZED
@@ -139,7 +139,7 @@ namespace pmr
 #endif // ATOMIC_POINTER_LOCK_FREE == 2
 
 #ifdef _GLIBCXX_ATOMIC_MEM_RES_CAN_BE_CONSTANT_INITIALIZED
-    constant_init<atomic_mem_res> default_res{&newdel_res.obj};
+    __constinit constant_init<atomic_mem_res> default_res{&newdel_res.obj};
 #else
 # include "default_resource.h"
 #endif

Reply via email to