1 From 6bb71fdd8f7cc346d90fb14beb38b7297fc1ffd9 Mon Sep 17 00:00:00 2001
2 From: Andrey Semashev <andrey.semashev@gmail.com>
3 Date: Sun, 26 Jan 2014 13:58:48 +0400
4 Subject: [PATCH] Fixed incorrect initialization of 128-bit values, when no
5 native support for 128-bit integers is available.
8 boost/atomic/detail/cas128strong.hpp | 10 +++++++---
9 1 file changed, 7 insertions(+), 3 deletions(-)
11 diff --git a/boost/atomic/detail/cas128strong.hpp b/boost/atomic/detail/cas128strong.hpp
12 index 906c13e..dcb4d7d 100644
13 --- a/boost/atomic/detail/cas128strong.hpp
14 +++ b/boost/atomic/detail/cas128strong.hpp
15 @@ -196,15 +196,17 @@ class base_atomic<T, void, 16, Sign>
18 BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
19 - explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : v_(0)
20 + explicit base_atomic(value_type const& v) BOOST_NOEXCEPT
22 + memset(&v_, 0, sizeof(v_));
23 memcpy(&v_, &v, sizeof(value_type));
27 store(value_type const& value, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
29 - storage_type value_s = 0;
30 + storage_type value_s;
31 + memset(&value_s, 0, sizeof(value_s));
32 memcpy(&value_s, &value, sizeof(value_type));
33 platform_fence_before_store(order);
34 platform_store128(value_s, &v_);
35 @@ -247,7 +249,9 @@ class base_atomic<T, void, 16, Sign>
36 memory_order success_order,
37 memory_order failure_order) volatile BOOST_NOEXCEPT
39 - storage_type expected_s = 0, desired_s = 0;
40 + storage_type expected_s, desired_s;
41 + memset(&expected_s, 0, sizeof(expected_s));
42 + memset(&desired_s, 0, sizeof(desired_s));
43 memcpy(&expected_s, &expected, sizeof(value_type));
44 memcpy(&desired_s, &desired, sizeof(value_type));