rsmith added a subscriber: rsmith. ================ Comment at: test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/constinit.pass.cpp:19-23 @@ +18,6 @@ + +_LIBCPP_SAFE_STATIC static std::unique_ptr<int> a; + +int main() { + assert(a == nullptr); +} ---------------- This is a bit painful to test without _LIBCPP_SAFE_STATIC, because the contents of `a` will be all 0 bits on program startup regardless of whether static or dynamic initialization is performed. Something like this might work though:
extern std::unique_ptr<int> a; void *trample = std::memset(&a, 0xab, sizeof(a)); _LIBCPP_SAFE_STATIC std::unique_ptr<int> a; int main() { // Check that the initialization of 'a' was performed before the initialization of 'trample'. for (size_t n = 0; n != sizeof(a); ++n) assert(reinterpret_cast<char*>(trample)[n] == 0xab); // Put a unique_ptr object back so that the global dtor is valid. new (&a) std::unique_ptr<int>; } Repository: rL LLVM https://reviews.llvm.org/D24372 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits