Skip to content

Commit 93f45d0

Browse files
committed
partially revert 'fix bug for static init'
re: 28836b8 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.
1 parent 6f6ddaa commit 93f45d0

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Diff for: include/json/value.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,11 @@ class JSON_API Value {
160160
typedef Json::LargestUInt LargestUInt;
161161
typedef Json::ArrayIndex ArrayIndex;
162162

163-
static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value().
164-
static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null
163+
static const Value& nullRef;
164+
#if !defined(__ARMEL__)
165+
/// \deprecated This exists for binary compatibility only. Use nullRef.
166+
static const Value null;
167+
#endif
165168
/// Minimum signed integer value that can be stored in a Json::Value.
166169
static const LargestInt minLargestInt;
167170
/// Maximum signed integer value that can be stored in a Json::Value.

Diff for: src/lib_json/json_value.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ namespace Json {
2929
#if defined(__ARMEL__)
3030
#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
3131
#else
32+
// This exists for binary compatibility only. Use nullRef.
33+
const Value Value::null;
3234
#define ALIGNAS(byte_alignment)
3335
#endif
3436
static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
3537
const unsigned char& kNullRef = kNull[0];
36-
const Value& Value::null = reinterpret_cast<const Value&>(kNullRef);
37-
const Value& Value::nullRef = null;
38+
const Value& Value::nullRef = reinterpret_cast<const Value&>(kNullRef);
3839

3940
const Int Value::minInt = Int(~(UInt(-1) / 2));
4041
const Int Value::maxInt = Int(UInt(-1) / 2);

0 commit comments

Comments
 (0)