Skip to content

Commit 3515db1

Browse files
committed
Merge pull request open-source-parsers#29 from mloy/type-punned-pointer
Type punned pointer I'll revert this if anyone reports a problem. *strict-aliasing* is not my favorite compiler warning.
2 parents 1a6426a + 48d9a92 commit 3515db1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/lib_json/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ ELSE(JSONCPP_LIB_BUILD_SHARED)
77
ENDIF(JSONCPP_LIB_BUILD_SHARED)
88

99

10+
if( CMAKE_COMPILER_IS_GNUCXX )
11+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing")
12+
endif( CMAKE_COMPILER_IS_GNUCXX )
13+
1014
SET( JSONCPP_INCLUDE_DIR ../../include )
1115

1216
SET( PUBLIC_HEADERS

src/lib_json/json_value.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ namespace Json {
3434
#define ALIGNAS(byte_alignment)
3535
#endif
3636
static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = {0};
37-
const Value& Value::null = reinterpret_cast<const Value&>(kNull);
37+
const unsigned char& kNullRef = kNull[0];
38+
const Value& Value::null = 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)