Fix static_string uninitialized warning

This commit is contained in:
Vinnie Falco
2018-11-22 08:05:39 -08:00
parent b9eb1d75d9
commit 2585625459
3 changed files with 13 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ Version 191:
* Use lean_tuple in bind_handler, bind_front_handler
* Use mp11 in detail::variant
* Fix buffers_cat uninitialized warning
* Fix static_string uninitialized warning
--------------------------------------------------------------------------------

View File

@@ -51,4 +51,13 @@
#define BOOST_BEAST_DEPRECATION_STRING \
"This is a deprecated interface, #define BOOST_BEAST_ALLOW_DEPRECATED to allow it"
#ifndef BOOST_BEAST_ASSUME
# ifdef BOOST_GCC
# define BOOST_BEAST_ASSUME(cond) \
do { if (!(cond)) __builtin_unreachable(); } while (0)
# else
# define BOOST_BEAST_ASSUME(cond) do { } while(0)
# endif
#endif
#endif

View File

@@ -139,7 +139,9 @@ assign(static_string const& str) ->
static_string&
{
n_ = str.n_;
Traits::copy(&s_[0], &str.s_[0], n_ + 1);
auto const n = n_ + 1;
BOOST_BEAST_ASSUME(n != 0);
Traits::copy(&s_[0], &str.s_[0], n);
return *this;
}