File tree 2 files changed +12
-2
lines changed 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ class JSON_API Value {
133
133
typedef Json::LargestUInt LargestUInt;
134
134
typedef Json::ArrayIndex ArrayIndex;
135
135
136
- static const Value null;
136
+ static const Value& null;
137
137
// / Minimum signed integer value that can be stored in a Json::Value.
138
138
static const LargestInt minLargestInt;
139
139
// / Maximum signed integer value that can be stored in a Json::Value.
Original file line number Diff line number Diff line change 25
25
26
26
namespace Json {
27
27
28
- const Value Value::null;
28
+ // This is a walkaround to avoid the static initialization of Value::null.
29
+ // kNull must be word-aligned to avoid crashing on ARM. We use an alignment of
30
+ // 8 (instead of 4) as a bit of future-proofing.
31
+ #if defined(__ARMEL__)
32
+ #define ALIGNAS (byte_alignment ) __attribute__((aligned(byte_alignment)))
33
+ #else
34
+ #define ALIGNAS (byte_alignment )
35
+ #endif
36
+ static const unsigned char ALIGNAS (8 ) kNull [sizeof (Value)] = {0 };
37
+ const Value& Value::null = reinterpret_cast <const Value&>(kNull );
38
+
29
39
const Int Value::minInt = Int (~(UInt (-1 ) / 2 ));
30
40
const Int Value::maxInt = Int (UInt (-1 ) / 2 );
31
41
const UInt Value::maxUInt = UInt (-1 );
You can’t perform that action at this time.
0 commit comments