From f3aa9c120177e4e5d4ab3e70b82224d83b711a96 Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Thu, 29 Jan 2015 14:02:56 -0600 Subject: [PATCH] partially revert 'fix bug for static init' re: 28836b8acc2c002b0488c13dba28fd5be864970a A global instance of a Value (viz. 'null') was a mistake, but dropping it breaks binary-compatibility. So we will keep it everywhere except the one platform where it was crashing, ARM. --- include/json/value.h | 7 +++++-- src/lib_json/json_value.cpp | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/json/value.h b/include/json/value.h index b2bd136..8e9548f 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -160,8 +160,11 @@ public: typedef Json::LargestUInt LargestUInt; typedef Json::ArrayIndex ArrayIndex; - static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value(). - static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null + static const Value& nullRef; +#if !defined(__ARMEL__) + /// \deprecated This exists for binary compatibility only. Use nullRef. + static const Value null; +#endif /// Minimum signed integer value that can be stored in a Json::Value. static const LargestInt minLargestInt; /// Maximum signed integer value that can be stored in a Json::Value. diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index c770c0b..5a7a548 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -29,12 +29,13 @@ namespace Json { #if defined(__ARMEL__) #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) #else +// This exists for binary compatibility only. Use nullRef. +const Value Value::null; #define ALIGNAS(byte_alignment) #endif static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 }; const unsigned char& kNullRef = kNull[0]; -const Value& Value::null = reinterpret_cast(kNullRef); -const Value& Value::nullRef = null; +const Value& Value::nullRef = reinterpret_cast(kNullRef); const Int Value::minInt = Int(~(UInt(-1) / 2)); const Int Value::maxInt = Int(UInt(-1) / 2);