From 696c4169fc9958a079fcf71a0c104aa071d796e1 Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Tue, 11 Jul 2017 16:47:50 -0700 Subject: [PATCH] Suppress incorrect GCC warning: GCC will something generate an incorrect warning when compiling Beast with the -Wmaybe-uninitialized flag. For more details, see http://www.boost.org/doc/libs/1_64_0/libs/optional/doc/html/boost_optional/tutorial/gotchas/false_positive_with__wmaybe_uninitialized.html --- CHANGELOG.md | 1 + include/beast/zlib/detail/deflate_stream.hpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 648b2794..a3d74544 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Version 81: * Pass string_view by value * better is_final on empty_base_optimization +* Suppress incorrect GCC warning -------------------------------------------------------------------------------- diff --git a/include/beast/zlib/detail/deflate_stream.hpp b/include/beast/zlib/detail/deflate_stream.hpp index b51baff1..e0574c98 100644 --- a/include/beast/zlib/detail/deflate_stream.hpp +++ b/include/beast/zlib/detail/deflate_stream.hpp @@ -1040,7 +1040,10 @@ doWrite(z_params& zs, boost::optional flush, error_code& ec) } // value of flush param for previous deflate call - boost::optional old_flush = last_flush_; + auto old_flush = boost::make_optional( + last_flush_.is_initialized(), + last_flush_ ? *last_flush_ : Flush::none); + last_flush_ = flush; // Flush as much pending output as possible