From 58ce1c8dcbb336785617caa1d6842f07f2ae20b3 Mon Sep 17 00:00:00 2001 From: Valeriy Kopylov Date: Mon, 17 Nov 2014 18:36:10 +0300 Subject: Disable clang optimization on extract_list_front() for OSX --- Rx/v2/src/rxcpp/rx-util.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Rx/v2/src/rxcpp/rx-util.hpp') diff --git a/Rx/v2/src/rxcpp/rx-util.hpp b/Rx/v2/src/rxcpp/rx-util.hpp index 7a83b7d..172720c 100644 --- a/Rx/v2/src/rxcpp/rx-util.hpp +++ b/Rx/v2/src/rxcpp/rx-util.hpp @@ -593,15 +593,24 @@ struct list_not_empty { }; struct extract_list_front { + // Clang optimisation loses moved list.front() value after list.pop_front(), so optimization must be switched off. template -#if defined(__clang__) +#if defined(__clang__) && defined(__linux__) + // Clang on Linux has an attribute to forbid optimization __attribute__((optnone)) #endif auto operator()(std::list& list) const -> decltype(std::move(list.front())) { +#if defined(__clang__) && !defined(__linux__) + // Clang on OSX doesn't support the attribute + volatile auto val = std::move(list.front()); + list.pop_front(); + return std::move(const_cast(val)); +#else auto val = std::move(list.front()); list.pop_front(); return std::move(val); +#endif } }; -- cgit v1.2.3