Fix static_string uninitialized warning

This commit is contained in:
Vinnie Falco committed 2018-11-22 08:08:55 -08:00
1 parent b9eb1d75d9
commit 2585625459
3 files changed
+13 -1

No files matched your search

+1
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
--------------------------------------------------------------------------------
@@ -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
@@ -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;
}