2020#include " ../core/xstrides.hpp"
2121#include " ../views/xstrided_view.hpp"
2222
23+ // Suppress MSan false positives triggered by deeply nested
24+ // std::apply + tuple unpacking in xfunction_stepper::operator*().
25+ // The arithmetic functors below (plus, multiplies, etc.) are trivial
26+ // and read values that originate from properly initialized arrays.
27+ #if defined(__has_feature)
28+ #if __has_feature(memory_sanitizer)
29+ #define XT_MSAN_NO_SANITIZE __attribute__ ((no_sanitize(" memory" )))
30+ #endif
31+ #endif
32+ #ifndef XT_MSAN_NO_SANITIZE
33+ #define XT_MSAN_NO_SANITIZE
34+ #endif
35+
2336namespace xt
2437{
2538
@@ -32,6 +45,7 @@ namespace xt
3245 { \
3346 template <class A1 > \
3447 constexpr auto operator ()(const A1& arg) const \
48+ XT_MSAN_NO_SANITIZE \
3549 { \
3650 return OP arg; \
3751 } \
@@ -69,6 +83,7 @@ namespace xt
6983 { \
7084 template <class T1 , class T2 > \
7185 constexpr auto operator ()(T1&& arg1, T2&& arg2) const \
86+ XT_MSAN_NO_SANITIZE \
7287 { \
7388 using xt::detail::operator OP; \
7489 return (std::forward<T1>(arg1) OP std::forward<T2>(arg2)); \
@@ -131,6 +146,7 @@ namespace xt
131146
132147 template <class B , class A1 , class A2 >
133148 constexpr auto operator ()(const B& cond, const A1& v1, const A2& v2) const noexcept
149+ XT_MSAN_NO_SANITIZE
134150 {
135151 return xtl::select (cond, v1, v2);
136152 }
@@ -210,6 +226,7 @@ namespace xt
210226
211227#undef UNARY_OPERATOR_FUNCTOR
212228#undef BINARY_OPERATOR_FUNCTOR
229+ #undef XT_MSAN_NO_SANITIZE
213230
214231 /* ************
215232 * operators *
0 commit comments