diff --git a/CHANGELOG.md b/CHANGELOG.md index 2096a8b9..cb6afb8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ HEAD ---- * Fixed warning "unused variable" with GCC 4.4 (issue #912) +* Fixed warning "maybe uninitialized" (issue #909) v5.13.4 ------- diff --git a/src/ArduinoJson/JsonVariantImpl.hpp b/src/ArduinoJson/JsonVariantImpl.hpp index 98db39ac..f9fe7d7f 100644 --- a/src/ArduinoJson/JsonVariantImpl.hpp +++ b/src/ArduinoJson/JsonVariantImpl.hpp @@ -23,6 +23,7 @@ inline JsonVariant::JsonVariant(const JsonArray &array) { _content.asArray = const_cast(&array); } else { _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(&object); } else { _type = Internals::JSON_UNDEFINED; + _content.asObject = 0; // <- prevent warning 'maybe-uninitialized' } } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 49f5a6a1..b5f7be8a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -46,6 +46,12 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.6) add_compile_options(-Wnoexcept) 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() if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")