Fixed warning "maybe uninitialized" (issue #909)

This commit is contained in:
Benoit Blanchon
2019-02-28 12:20:46 +01:00
parent f483b06735
commit 5c297ba4a2
3 changed files with 9 additions and 0 deletions

View File

@ -5,6 +5,7 @@ HEAD
---- ----
* Fixed warning "unused variable" with GCC 4.4 (issue #912) * Fixed warning "unused variable" with GCC 4.4 (issue #912)
* Fixed warning "maybe uninitialized" (issue #909)
v5.13.4 v5.13.4
------- -------

View File

@ -23,6 +23,7 @@ inline JsonVariant::JsonVariant(const JsonArray &array) {
_content.asArray = const_cast<JsonArray *>(&array); _content.asArray = const_cast<JsonArray *>(&array);
} else { } else {
_type = Internals::JSON_UNDEFINED; _type = Internals::JSON_UNDEFINED;
_content.asArray = 0; // <- prevent warning 'maybe-uninitialized'
} }
} }
@ -32,6 +33,7 @@ inline JsonVariant::JsonVariant(const JsonObject &object) {
_content.asObject = const_cast<JsonObject *>(&object); _content.asObject = const_cast<JsonObject *>(&object);
} else { } else {
_type = Internals::JSON_UNDEFINED; _type = Internals::JSON_UNDEFINED;
_content.asObject = 0; // <- prevent warning 'maybe-uninitialized'
} }
} }

View File

@ -46,6 +46,12 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.6) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.6)
add_compile_options(-Wnoexcept) add_compile_options(-Wnoexcept)
endif() endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.7 AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
# avoid false positive with GCC 4.7
add_compile_options(-Wno-maybe-uninitialized)
endif()
endif() endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")