From 0390b1ad5753f94284bba8c7fa8acb97640b9212 Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Fri, 6 May 2022 16:03:36 -0700 Subject: [PATCH] Avoid exit-time destructors. operator[]() was recently changed to use the existing code in order to correctly align the returned pointer; however this broke -Wexit-time-destructors. Change to a method that is still correctly aligned but does not generate a destructor. --- include/rapidjson/document.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 74089cb..ea6d806 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -1235,8 +1235,8 @@ public: // return NullValue; // Use static buffer and placement-new to prevent destruction - static GenericValue buffer; - return *new (reinterpret_cast(&buffer)) GenericValue(); + alignas(GenericValue) static char buffer[sizeof(GenericValue)]; + return *new (buffer) GenericValue(); } } template