From b72896d3e90c41dc2116f036be71cf9ed27e82c2 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Thu, 16 May 2019 09:20:52 +0200 Subject: [PATCH] refactored __attribute__ conditional insertion to cater for potential warnings --- .../detail/stride_iterator.hpp | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/include/boost/poly_collection/detail/stride_iterator.hpp b/include/boost/poly_collection/detail/stride_iterator.hpp index 02e9eae..ec0de42 100644 --- a/include/boost/poly_collection/detail/stride_iterator.hpp +++ b/include/boost/poly_collection/detail/stride_iterator.hpp @@ -73,6 +73,23 @@ public: explicit stride_iterator(DerivedValue* x)noexcept: p{x},stride_{sizeof(DerivedValue)}{} +#if BOOST_WORKAROUND(BOOST_GCC_VERSION,>=40900)||\ + BOOST_WORKAROUND(BOOST_CLANG,>=1)&&\ + (__clang_major__>3 || __clang_major__==3 && __clang_minor__ >= 8) +/* https://github.com/boostorg/poly_collection/issues/15 */ + +#define BOOST_POLY_COLLECTION_NO_SANITIZE + +/* UBSan seems not to be supported in some environments */ +#if defined(BOOST_GCC_VERSION) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wattributes" +#elif defined(BOOST_CLANG) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wattributes" +#endif +#endif + template< typename DerivedValue, typename std::enable_if< @@ -80,16 +97,22 @@ public: (!std::is_const::value||std::is_const::value) >::type* =nullptr > -#if BOOST_WORKAROUND(BOOST_GCC_VERSION,>=40900)||\ - BOOST_WORKAROUND(BOOST_CLANG,>=1)&&\ - (__clang_major__>3 || __clang_major__==3 && __clang_minor__ >= 8) - /* https://github.com/boostorg/poly_collection/issues/15 */ - +#if defined(BOOST_POLY_COLLECTION_NO_SANITIZE) __attribute__((no_sanitize("undefined"))) #endif explicit operator DerivedValue*()const noexcept {return static_cast(p);} +#if defined(BOOST_POLY_COLLECTION_NO_SANITIZE) +#if defined(BOOST_GCC_VERSION) +#pragma GCC diagnostic pop +#elif defined(BOOST_CLANG) +#pragma clang diagnostic pop +#endif + +#undef BOOST_POLY_COLLECTION_NO_SANITIZE +#endif + std::size_t stride()const noexcept{return stride_;} private: