From 787adc24b2d1a7a3c03ecfed57de27631359ef65 Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 30 Jan 2017 17:10:01 +0100 Subject: Fixed clang segmentation fault in nopch mode --- src/server/database/Database/QueryCallback.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/server/database/Database/QueryCallback.cpp') diff --git a/src/server/database/Database/QueryCallback.cpp b/src/server/database/Database/QueryCallback.cpp index 96361e54ede..2d89e08a956 100644 --- a/src/server/database/Database/QueryCallback.cpp +++ b/src/server/database/Database/QueryCallback.cpp @@ -17,10 +17,10 @@ #include "QueryCallback.h" -template -inline void Construct(T& t) +template +inline void Construct(T& t, Args&&... args) { - new (&t) T(); + new (&t) T(std::forward(args)...); } template @@ -103,12 +103,17 @@ private: bool _isPrepared; }; -QueryCallback::QueryCallback(std::future&& result) : _string(std::move(result)), _isPrepared(false) +// Not using initialization lists to work around segmentation faults when compiling with clang without precompiled headers +QueryCallback::QueryCallback(std::future&& result) { + _isPrepared = false; + Construct(_string, std::move(result)); } -QueryCallback::QueryCallback(std::future&& result) : _prepared(std::move(result)), _isPrepared(true) +QueryCallback::QueryCallback(std::future&& result) { + _isPrepared = true; + Construct(_prepared, std::move(result)); } QueryCallback::QueryCallback(QueryCallback&& right) -- cgit v1.2.3