Squelch spurious warning on gcc

This commit is contained in:
Vinnie Falco
2017-06-23 10:42:02 -07:00
parent e389b853c5
commit 9f0dbb4265
2 changed files with 11 additions and 5 deletions

View File

@@ -10,6 +10,7 @@ Version 66:
* Add header aliases * Add header aliases
* basic_fields optimizations * basic_fields optimizations
* Add http-server example * Add http-server example
* Squelch spurious warning on gcc
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@@ -39,6 +39,7 @@
#include <beast/zlib/detail/ranges.hpp> #include <beast/zlib/detail/ranges.hpp>
#include <beast/core/detail/type_traits.hpp> #include <beast/core/detail/type_traits.hpp>
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/throw_exception.hpp> #include <boost/throw_exception.hpp>
#include <cstdint> #include <cstdint>
@@ -667,7 +668,7 @@ protected:
template<class = void> std::size_t doUpperBound (std::size_t sourceLen) const; template<class = void> std::size_t doUpperBound (std::size_t sourceLen) const;
template<class = void> void doTune (int good_length, int max_lazy, int nice_length, int max_chain); template<class = void> void doTune (int good_length, int max_lazy, int nice_length, int max_chain);
template<class = void> void doParams (z_params& zs, int level, Strategy strategy, error_code& ec); template<class = void> void doParams (z_params& zs, int level, Strategy strategy, error_code& ec);
template<class = void> void doWrite (z_params& zs, Flush flush, error_code& ec); template<class = void> void doWrite (z_params& zs, boost::optional<Flush> flush, error_code& ec);
template<class = void> void doDictionary (Byte const* dict, uInt dictLength, error_code& ec); template<class = void> void doDictionary (Byte const* dict, uInt dictLength, error_code& ec);
template<class = void> void doPrime (int bits, int value, error_code& ec); template<class = void> void doPrime (int bits, int value, error_code& ec);
template<class = void> void doPending (unsigned* value, int* bits); template<class = void> void doPending (unsigned* value, int* bits);
@@ -1014,10 +1015,14 @@ doParams(z_params& zs, int level, Strategy strategy, error_code& ec)
strategy_ = strategy; strategy_ = strategy;
} }
// VFALCO boost::optional param is a workaround for
// gcc "maybe uninitialized" warning
// https://github.com/vinniefalco/Beast/issues/532
//
template<class> template<class>
void void
deflate_stream:: deflate_stream::
doWrite(z_params& zs, Flush flush, error_code& ec) doWrite(z_params& zs, boost::optional<Flush> flush, error_code& ec)
{ {
maybe_init(); maybe_init();
@@ -1081,14 +1086,14 @@ doWrite(z_params& zs, Flush flush, error_code& ec)
switch(strategy_) switch(strategy_)
{ {
case Strategy::huffman: case Strategy::huffman:
bstate = deflate_huff(zs, flush); bstate = deflate_huff(zs, flush.get());
break; break;
case Strategy::rle: case Strategy::rle:
bstate = deflate_rle(zs, flush); bstate = deflate_rle(zs, flush.get());
break; break;
default: default:
{ {
bstate = (this->*(get_config(level_).func))(zs, flush); bstate = (this->*(get_config(level_).func))(zs, flush.get());
break; break;
} }
} }