From f6443f3d661b23f68b54db278573af15a7e08d0b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 12 Dec 2018 15:11:15 +0100 Subject: logic/pipeline: fix nan check It assumed that all values were of the same type when packing into an initializer list. --- logic/pipeline.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'logic/pipeline.cpp') diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp index 64adf9c8..a2aaa9f3 100644 --- a/logic/pipeline.cpp +++ b/logic/pipeline.cpp @@ -218,7 +218,7 @@ bool is_nan(const dmat& r) return false; } -static cc_forceinline +static cc_noinline void emit_nan_check_msg(const char* text, const char* fun, int line) { eval_once( @@ -233,26 +233,21 @@ template static cc_noinline bool maybe_nan(const char* text, const char* fun, int line, const xs&... vals) { - for (const auto& x : { vals... }) - if (is_nan(x)) - { - emit_nan_check_msg(text, fun, line); - return true; - } - return false; + bool ret = (is_nan(vals) || ... || true); + + if (ret) + emit_nan_check_msg(text, fun, line); + + return true; } #define nan_check(...) \ do \ { \ if (likely(!maybe_nan(#__VA_ARGS__, cc_function_name, __LINE__, __VA_ARGS__))) \ - { \ (void)0; \ - } \ else \ - { \ goto error; \ - } \ } \ while (false) -- cgit v1.2.3