Skip to content

Commit e753cc5

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 7b304c2 commit e753cc5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

include/json/value.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,11 @@ class JSON_API Value {
134134
typedef Json::LargestUInt LargestUInt;
135135
typedef Json::ArrayIndex ArrayIndex;
136136

137-
static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value().
138-
static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null
137+
static const Value& nullRef;
138+
#if !defined(__ARMEL__)
139+
/// \deprecated This exists for binary compatibility only. Use nullRef.
140+
static const Value null;
141+
#endif
139142
/// Minimum signed integer value that can be stored in a Json::Value.
140143
static const LargestInt minLargestInt;
141144
/// Maximum signed integer value that can be stored in a Json::Value.

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)