diff --git a/.clang-format b/.clang-format index dceab5d5..485de367 100644 --- a/.clang-format +++ b/.clang-format @@ -46,6 +46,7 @@ IncludeCategories: - Regex: '".+"' Priority: 5 IndentCaseLabels: true +IndentPPDirectives: AfterHash IndentWidth: '4' IndentWrappedFunctionNames: false InsertBraces: true diff --git a/include/sparrow/allocator.hpp b/include/sparrow/allocator.hpp index 3ef93af4..a1283ab0 100644 --- a/include/sparrow/allocator.hpp +++ b/include/sparrow/allocator.hpp @@ -231,7 +231,14 @@ namespace sparrow return visit_storage( [n, p](auto& allocator) { +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmismatched-new-delete" +#endif return allocator.deallocate(p, n); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } ); } diff --git a/include/sparrow/array_data.hpp b/include/sparrow/array_data.hpp index 4c6dd91f..f730decf 100644 --- a/include/sparrow/array_data.hpp +++ b/include/sparrow/array_data.hpp @@ -18,12 +18,13 @@ #include #include -#include "sparrow/contracts.hpp" #include "sparrow/buffer.hpp" +#include "sparrow/contracts.hpp" #include "sparrow/data_type.hpp" #include "sparrow/dynamic_bitset.hpp" #include "sparrow/memory.hpp" + namespace sparrow { /** diff --git a/include/sparrow/buffer.hpp b/include/sparrow/buffer.hpp index 49f598cb..29dbb21c 100644 --- a/include/sparrow/buffer.hpp +++ b/include/sparrow/buffer.hpp @@ -20,11 +20,12 @@ #include #include -#include "sparrow/contracts.hpp" #include "sparrow/allocator.hpp" +#include "sparrow/contracts.hpp" #include "sparrow/iterator.hpp" #include "sparrow/mp_utils.hpp" + namespace sparrow { @@ -312,7 +313,7 @@ namespace sparrow template buffer_base::~buffer_base() { - deallocate(m_data.p_begin, (m_data.p_storage_end - m_data.p_begin)); + deallocate(m_data.p_begin, static_cast(m_data.p_storage_end - m_data.p_begin)); } template @@ -414,7 +415,7 @@ namespace sparrow template template constexpr buffer::buffer(It first, It last, const A& a) - : base_type(check_init_length(std::distance(first, last), a), a) + : base_type(check_init_length(static_cast(std::distance(first, last)), a), a) { get_data().p_end = copy_initialize(first, last, get_data().p_begin, get_allocator()); } @@ -666,7 +667,10 @@ namespace sparrow std::make_move_iterator(get_data().p_end) ); destroy(get_data().p_begin, get_data().p_end, get_allocator()); - this->deallocate(get_data().p_begin, get_data().p_storage_end - get_data().p_begin); + this->deallocate( + get_data().p_begin, + static_cast(get_data().p_storage_end - get_data().p_begin) + ); this->assign_storage(tmp, old_size, new_cap); } } @@ -744,7 +748,7 @@ namespace sparrow constexpr void buffer::assign_range_impl(It first, It last, std::forward_iterator_tag) { const size_type sz = size(); - const size_type len = std::distance(first, last); + const size_type len = static_cast(std::distance(first, last)); if (len > capacity()) { check_init_length(len, get_allocator()); @@ -804,7 +808,7 @@ namespace sparrow template constexpr auto buffer::max_size_impl(const allocator_type& a) noexcept -> size_type { - const size_type diff_max = std::numeric_limits::max(); + const size_type diff_max = static_cast(std::numeric_limits::max()); const size_type alloc_max = std::allocator_traits::max_size(a); return (std::min)(diff_max, alloc_max); } diff --git a/include/sparrow/buffer_view.hpp b/include/sparrow/buffer_view.hpp index 7c7399ee..29d9c108 100644 --- a/include/sparrow/buffer_view.hpp +++ b/include/sparrow/buffer_view.hpp @@ -15,6 +15,7 @@ #pragma once #include "sparrow/buffer.hpp" +#include "sparrow/contracts.hpp" namespace sparrow { @@ -23,7 +24,7 @@ namespace sparrow * * Although this class looks very similar to std::span, it provides * methods that are missing in C++20 std::span (like cbegin / cend), - * and additional std::vector-like APIs. + * and additional std::vector-like APIs. */ template class buffer_view @@ -130,42 +131,42 @@ namespace sparrow template auto buffer_view::operator[](size_type pos) -> reference { - assert(pos < size()); + SPARROW_ASSERT_TRUE(pos < size()); return data()[pos]; } template auto buffer_view::operator[](size_type pos) const -> const_reference { - assert(pos < size()); + SPARROW_ASSERT_TRUE(pos < size()); return data()[pos]; } template auto buffer_view::front() -> reference { - assert(!empty()); + SPARROW_ASSERT_TRUE(!empty()); return data()[0]; } template auto buffer_view::front() const -> const_reference { - assert(!empty()); + SPARROW_ASSERT_TRUE(!empty()); return data()[0]; } template auto buffer_view::back() -> reference { - assert(!empty()); + SPARROW_ASSERT_TRUE(!empty()); return data()[m_size - 1]; } template auto buffer_view::back() const -> const_reference { - assert(!empty()); + SPARROW_ASSERT_TRUE(!empty()); return data()[m_size - 1]; } diff --git a/include/sparrow/contracts.hpp b/include/sparrow/contracts.hpp index cb0c4b35..d5c9ad05 100644 --- a/include/sparrow/contracts.hpp +++ b/include/sparrow/contracts.hpp @@ -12,12 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -// NOTE: This is based upon v0.3.0 of NoContracts library https://github.com/Klaim/nocontracts/tree/0ffc183f7527213e3f0a57b8dae9befa7c0ca02c +// NOTE: This is based upon v0.3.0 of NoContracts library +// https://github.com/Klaim/nocontracts/tree/0ffc183f7527213e3f0a57b8dae9befa7c0ca02c // Modifications: renamed macros #pragma once -#include #include +#include /////////////////////////////////////////////////////////////////// @@ -25,79 +26,114 @@ // if not specified by the user but available, use std::print #if not defined(SPARROW_CONTRACTS_USE_STD_PRINT) and not defined(SPARROW_CONTRACTS_USE_STD_FORMAT) -# if __cplusplus >= 202002L -# include -# ifdef __cpp_lib_print -# define SPARROW_CONTRACTS_USE_STD_PRINT 1 -# endif -# endif +# if __cplusplus >= 202002L +# include +# ifdef __cpp_lib_print +# define SPARROW_CONTRACTS_USE_STD_PRINT 1 +# endif +# endif #else // The option is defined, but is it supported? If not we fail. -# if defined(SPARROW_CONTRACTS_USE_STD_PRINT) and not defined(__cpp_lib_print) -# error "std::print usage is requested but not available" -# endif +# if defined(SPARROW_CONTRACTS_USE_STD_PRINT) and not defined(__cpp_lib_print) +# error "std::print usage is requested but not available" +# endif #endif // if not specified by the user but available and std::print is not already forced, use std::format #if not defined(SPARROW_CONTRACTS_USE_STD_FORMAT) and not defined(SPARROW_CONTRACTS_USE_STD_PRINT) -# if __cplusplus >= 202002L -# include -# ifdef __cpp_lib_format -# define SPARROW_CONTRACTS_USE_STD_FORMAT 1 -# endif -# endif +# if __cplusplus >= 202002L +# include +# ifdef __cpp_lib_format +# define SPARROW_CONTRACTS_USE_STD_FORMAT 1 +# endif +# endif // The option is defined, but is it supported? If not we fail. -# if defined(SPARROW_CONTRACTS_USE_STD_FORMAT) and not defined(__cpp_lib_format) -# error "std::format usage is requested but not available" -# endif +# if defined(SPARROW_CONTRACTS_USE_STD_FORMAT) and not defined(__cpp_lib_format) +# error "std::format usage is requested but not available" +# endif #endif // user specified to use neither std::format nor std::print, but C's formatting #if defined(SPARROW_CONTRACTS_USE_CFORMAT) && SPARROW_CONTRACTS_USE_CFORMAT == 1 -# ifdef SPARROW_CONTRACTS_USE_STD_FORMAT -# undef SPARROW_CONTRACTS_USE_STD_FORMAT -# endif -# ifdef SPARROW_CONTRACTS_USE_STD_PRINT -# undef SPARROW_CONTRACTS_USE_STD_PRINT -# endif +# ifdef SPARROW_CONTRACTS_USE_STD_FORMAT +# undef SPARROW_CONTRACTS_USE_STD_FORMAT +# endif +# ifdef SPARROW_CONTRACTS_USE_STD_PRINT +# undef SPARROW_CONTRACTS_USE_STD_PRINT +# endif +#endif + +// clang-format off +#if defined(__GNUC__) +# define SPARROW_CONTRACTS_IGNORE_WARNINGS \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wall\"") \ + _Pragma("GCC diagnostic ignored \"-Wformat-security\"") +# define SPARROW_CONTRACTS_RESTORE_WARNINGS \ + _Pragma("GCC diagnostic pop") +#elif defined(__clang__) +# define SPARROW_CONTRACTS_IGNORE_WARNINGS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Weverything\"") +# define SPARROW_CONTRACTS_RESTORE_WARNINGS \ + _Pragma("clang diagnostic pop") +#elif defined(_MSC_VER) +# define SPARROW_CONTRACTS_IGNORE_WARNINGS \ + _Pragma("warning(push)") \ + _Pragma("warning(disable : 4774)") // 'var' has different type in 'file1' and 'file2': 'type1' and 'type2' +# define SPARROW_CONTRACTS_RESTORE_WARNINGS \ + _Pragma("warning(pop)") +#else +# define SPARROW_CONTRACTS_IGNORE_WARNINGS +# define SPARROW_CONTRACTS_RESTORE_WARNINGS #endif +// clang-format on #ifndef SPARROW_CONTRACTS_LOG_FAILURE -# if defined(SPARROW_CONTRACTS_USE_STD_PRINT) && SPARROW_CONTRACTS_USE_STD_PRINT == 1 -# include -# include -# define SPARROW_CONTRACTS_LOG_FAILURE( expr__, message__ ) \ - ::std::print(stderr, "Assertion Failed ({}:{}): {} - ({} is wrong)\n", __FILE__, __LINE__, message__, #expr__ ) -# elif defined(SPARROW_CONTRACTS_USE_STD_FORMAT) && SPARROW_CONTRACTS_USE_STD_FORMAT == 1 -# include -# include +# if defined(SPARROW_CONTRACTS_USE_STD_PRINT) && SPARROW_CONTRACTS_USE_STD_PRINT == 1 +# include +# include +// clang-format off +# define SPARROW_CONTRACTS_LOG_FAILURE(expr__, message__) \ + ::std::print(stderr, "Assertion Failed ({}:{}): {} - ({} is wrong)\n", __FILE__, __LINE__, message__, #expr__) +// clang-format on +# elif defined(SPARROW_CONTRACTS_USE_STD_FORMAT) && SPARROW_CONTRACTS_USE_STD_FORMAT == 1 +# include +# include +// clang-format off # define SPARROW_CONTRACTS_LOG_FAILURE( expr__, message__ ) \ - ::fprintf(stderr, ::std::format("Assertion Failed ({}:{}): {} - ({} is wrong)\n", __FILE__, __LINE__, message__, #expr__ ).c_str()) -# else -# include -# include -# define SPARROW_CONTRACTS_LOG_FAILURE( expr__, message__ ) \ - ::fprintf(stderr, "Assertion Failed (%s:%i): %s - (%s is wrong)\n", __FILE__, __LINE__, message__, #expr__ ) -# endif + do { \ + SPARROW_CONTRACTS_IGNORE_WARNINGS; \ + ::fprintf(stderr, ::std::format("Assertion Failed ({}:{}): {} - ({} is wrong)\n", __FILE__, __LINE__, message__, #expr__ ).c_str()); \ + SPARROW_CONTRACTS_RESTORE_WARNINGS; \ + } while (0); +// clang-format on +# else +# include +# include +// clang-format off +# define SPARROW_CONTRACTS_LOG_FAILURE(expr__, message__) \ + ::fprintf(stderr, "Assertion Failed (%s:%i): %s - (%s is wrong)\n", __FILE__, __LINE__, message__, #expr__); +// clang-format on +# endif #endif #ifndef SPARROW_CONTRACTS_ABORT -# define SPARROW_CONTRACTS_ABORT() \ - std::abort() +# define SPARROW_CONTRACTS_ABORT() std::abort() #endif // User specifies to just continue instead of abort on failure. #if defined(SPARROW_CONTRACTS_CONTINUE_ON_FAILURE) and SPARROW_CONTRACTS_CONTINUE_ON_FAILURE == 1 -# undef SPARROW_CONTRACTS_ABORT -# define SPARROW_CONTRACTS_ABORT +# undef SPARROW_CONTRACTS_ABORT +# define SPARROW_CONTRACTS_ABORT #endif #ifndef SPARROW_CONTRACTS_DEBUGBREAK -# ifdef _WIN32 -# define SPARROW_CONTRACTS_DEBUGBREAK() __debugbreak(); -# else -# define SPARROW_CONTRACTS_DEBUGBREAK() std::raise(SIGTRAP); -# endif +# ifdef _WIN32 +# define SPARROW_CONTRACTS_DEBUGBREAK() __debugbreak(); +# else +# define SPARROW_CONTRACTS_DEBUGBREAK() std::raise(SIGTRAP); +# endif #endif /////////////////////////////////////////////////////////////////// @@ -106,39 +142,40 @@ #define SPARROW_CONTRACTS_DEFAULT_CHECKS_ENABLED 1 #define SPARROW_CONTRACTS_DEFAULT_ABORT_ON_FAILURE 1 -#define SPARROW_CONTRACTS_DEFAULT_ON_FAILURE( expr__, message__ ) \ - SPARROW_CONTRACTS_LOG_FAILURE( expr__, message__ ); \ - SPARROW_CONTRACTS_DEBUGBREAK(); \ - SPARROW_CONTRACTS_ABORT(); +#define SPARROW_CONTRACTS_DEFAULT_ON_FAILURE(expr__, message__) \ + SPARROW_CONTRACTS_LOG_FAILURE(expr__, message__); \ + SPARROW_CONTRACTS_DEBUGBREAK(); \ + SPARROW_CONTRACTS_ABORT(); /////////////////////////////////////////////////////////////////// // Apply Configuration: // If not override, use the default behavior. #ifndef SPARROW_CONTRACTS_CHECKS_ENABLED -# define SPARROW_CONTRACTS_CHECKS_ENABLED SPARROW_CONTRACTS_DEFAULT_CHECKS_ENABLED +# define SPARROW_CONTRACTS_CHECKS_ENABLED SPARROW_CONTRACTS_DEFAULT_CHECKS_ENABLED #endif -#if SPARROW_CONTRACTS_CHECKS_ENABLED == 1 // Behavior when contracts are enabled. - -# ifndef SPARROW_CONTRACTS_ON_FAILURE -# define SPARROW_CONTRACTS_ON_FAILURE( expr__, message__ ) \ - SPARROW_CONTRACTS_DEFAULT_ON_FAILURE( expr__, message__ ) -# endif - -# ifndef SPARROW_ASSERT -# define SPARROW_ASSERT( expr__, message__ ) \ - if(!( expr__ )) \ - { SPARROW_CONTRACTS_ON_FAILURE( expr__, message__ ); } -# endif - -# define SPARROW_ASSERT_TRUE( expr__ ) SPARROW_ASSERT( expr__, #expr__ ) -# define SPARROW_ASSERT_FALSE( expr__ ) SPARROW_ASSERT( !(expr__), "!("#expr__")" ) - -# else // Do nothing otherwise. -# define SPARROW_CONTRACTS_ON_FAILURE( expr__ ) -# define SPARROW_ASSERT( expr__, message__ ) -# define SPARROW_ASSERT_TRUE( expr__ ) -# define SPARROW_ASSERT_FALSE( expr__ ) +#if SPARROW_CONTRACTS_CHECKS_ENABLED == 1 // Behavior when contracts are enabled. + +# ifndef SPARROW_CONTRACTS_ON_FAILURE +# define SPARROW_CONTRACTS_ON_FAILURE(expr__, message__) \ + SPARROW_CONTRACTS_DEFAULT_ON_FAILURE(expr__, message__) +# endif + +# ifndef SPARROW_ASSERT +# define SPARROW_ASSERT(expr__, message__) \ + if (!(expr__)) \ + { \ + SPARROW_CONTRACTS_ON_FAILURE(expr__, message__); \ + } +# endif + +# define SPARROW_ASSERT_TRUE(expr__) SPARROW_ASSERT(expr__, #expr__) +# define SPARROW_ASSERT_FALSE(expr__) SPARROW_ASSERT(!(expr__), "!(" #expr__ ")") + +#else // Do nothing otherwise. +# define SPARROW_CONTRACTS_ON_FAILURE(expr__) +# define SPARROW_ASSERT(expr__, message__) +# define SPARROW_ASSERT_TRUE(expr__) +# define SPARROW_ASSERT_FALSE(expr__) #endif - diff --git a/include/sparrow/data_type.hpp b/include/sparrow/data_type.hpp index ce811886..69656b00 100644 --- a/include/sparrow/data_type.hpp +++ b/include/sparrow/data_type.hpp @@ -25,9 +25,35 @@ // TODO: use exclusively `std::float16_t etc. once we switch to c++23, see // https://en.cppreference.com/w/cpp/types/floating-point #if __cplusplus <= 202002L -#include "details/3rdparty/float16_t.hpp" + // We disable some warnings for the 3rd party float16_t library +# if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wconversion" +# pragma clang diagnostic ignored "-Wsign-conversion" +# pragma clang diagnostic ignored "-Wold-style-cast" +# elif defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wconversion" +# pragma GCC diagnostic ignored "-Wsign-conversion" +# pragma GCC diagnostic ignored "-Wold-style-cast" +# elif defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable : 4365) // 'action' : conversion from 'type_1' to 'type_2', signed/unsigned + // mismatch +# pragma warning(disable : 4514) // 'function' : unreferenced inline function has been removed +# pragma warning(disable : 4668) // 'symbol' is not defined as a preprocessor macro, replacing with + // '0' for 'directives' +# endif +# include "details/3rdparty/float16_t.hpp" +# if defined(__GNUC__) +# pragma GCC diagnostic pop +# elif defined(__clang__) +# pragma clang diagnostic pop +# elif defined(_MSC_VER) +# pragma warning(pop) +# endif #else -#include +# include #endif diff --git a/include/sparrow/dictionary_encoded_layout.hpp b/include/sparrow/dictionary_encoded_layout.hpp index f1e5e1ec..c4cb18e7 100644 --- a/include/sparrow/dictionary_encoded_layout.hpp +++ b/include/sparrow/dictionary_encoded_layout.hpp @@ -14,12 +14,13 @@ #pragma once -#include "sparrow/contracts.hpp" #include "sparrow/array_data.hpp" +#include "sparrow/contracts.hpp" #include "sparrow/fixed_size_layout.hpp" #include "sparrow/iterator.hpp" #include "sparrow/mp_utils.hpp" + namespace sparrow { /** @@ -194,10 +195,10 @@ namespace sparrow template dictionary_value_iterator::dictionary_value_iterator( index_iterator index_it, - sub_layout_reference sub_layout_reference + sub_layout_reference sub_layout_ref ) : m_index_it(index_it) - , m_sub_layout_reference(sub_layout_reference) + , m_sub_layout_reference(sub_layout_ref) { } diff --git a/include/sparrow/dynamic_bitset.hpp b/include/sparrow/dynamic_bitset.hpp index d08e5022..8281500a 100644 --- a/include/sparrow/dynamic_bitset.hpp +++ b/include/sparrow/dynamic_bitset.hpp @@ -17,10 +17,11 @@ #include #include #include +#include -#include "sparrow/contracts.hpp" #include "sparrow/buffer.hpp" #include "sparrow/buffer_view.hpp" +#include "sparrow/contracts.hpp" #include "sparrow/mp_utils.hpp" namespace sparrow @@ -344,7 +345,7 @@ namespace sparrow } else { - block &= ~bit_mask(pos); + block &= block_type(~bit_mask(pos)); } update_null_count(old_value, value); } @@ -454,7 +455,8 @@ namespace sparrow template auto dynamic_bitset_base::bit_mask(size_type pos) noexcept -> block_type { - return block_type(1) << bit_index(pos); + const size_type bit = bit_index(pos); + return static_cast(block_type(1) << bit); } template @@ -500,7 +502,7 @@ namespace sparrow const size_type extra_bits = count_extra_bits(); if (extra_bits != 0) { - m_buffer.back() &= ~(~block_type(0) << extra_bits); + m_buffer.back() &= block_type(~(~block_type(0) << extra_bits)); } } @@ -522,7 +524,7 @@ namespace sparrow { const size_type old_block_count = m_buffer.size(); const size_type new_block_count = compute_block_count(n); - const block_type value = b ? ~block_type(0) : block_type(0); + const block_type value = b ? block_type(~block_type(0)) : block_type(0); if (new_block_count != old_block_count) { @@ -561,7 +563,11 @@ namespace sparrow template dynamic_bitset::dynamic_bitset(size_type n, value_type value) - : base_type(storage_type(this->compute_block_count(n), value ? ~block_type(0) : 0), n, value ? 0u : n) + : base_type( + storage_type(this->compute_block_count(n), value ? block_type(~block_type(0)) : block_type(0)), + n, + value ? 0u : n + ) { } @@ -748,30 +754,30 @@ namespace sparrow { if (n >= 0) { - if (m_index + n < bitset_type::s_bits_per_block) + if (std::cmp_less(n, bitset_type::s_bits_per_block - m_index)) { - m_index += n; + m_index += static_cast(n); } else { - size_type to_next_block = bitset_type::s_bits_per_block - m_index; - n -= to_next_block; - size_type block_n = n / bitset_type::s_bits_per_block; + const size_type to_next_block = bitset_type::s_bits_per_block - m_index; + n -= static_cast(to_next_block); + const size_type block_n = static_cast(n) / bitset_type::s_bits_per_block; p_block += block_n + 1; - n -= block_n * bitset_type::s_bits_per_block; - m_index = n; + n -= static_cast(block_n * bitset_type::s_bits_per_block); + m_index = static_cast(n); } } else { - difference_type mn = -n; + size_type mn = static_cast(-n); if (m_index >= mn) { m_index -= mn; } else { - size_type block_n = mn / bitset_type::s_bits_per_block; + const size_type block_n = mn / bitset_type::s_bits_per_block; p_block -= block_n; mn -= block_n * bitset_type::s_bits_per_block; if (m_index >= mn) @@ -794,12 +800,12 @@ namespace sparrow { if (p_block == rhs.p_block) { - return rhs.m_index - m_index; + return static_cast(rhs.m_index - m_index); } else { - auto dist1 = distance_to_begin(); - auto dist2 = rhs.distance_to_begin(); + const auto dist1 = distance_to_begin(); + const auto dist2 = rhs.distance_to_begin(); return dist2 - dist1; } } @@ -819,12 +825,15 @@ namespace sparrow template bool bitset_iterator::is_first_bit_of_block(size_type index) const { - return m_index % bitset_type::s_bits_per_block == 0; + return index % bitset_type::s_bits_per_block == 0; } template auto bitset_iterator::distance_to_begin() const -> difference_type { - return bitset_type::s_bits_per_block * (p_block - p_bitset->begin().p_block) + m_index; + const difference_type distance = p_block - p_bitset->begin().p_block; + SPARROW_ASSERT_TRUE(distance >= 0); + return static_cast(bitset_type::s_bits_per_block) * distance + + static_cast(m_index); } } diff --git a/include/sparrow/fixed_size_layout.hpp b/include/sparrow/fixed_size_layout.hpp index 0144393f..8105bbcf 100644 --- a/include/sparrow/fixed_size_layout.hpp +++ b/include/sparrow/fixed_size_layout.hpp @@ -17,10 +17,12 @@ #include #include #include +#include +#include -#include "sparrow/contracts.hpp" #include "sparrow/array_data.hpp" #include "sparrow/buffer.hpp" +#include "sparrow/contracts.hpp" #include "sparrow/dynamic_bitset.hpp" #include "sparrow/iterator.hpp" @@ -132,7 +134,7 @@ namespace sparrow { // We only require the presence of the bitmap and the first buffer. SPARROW_ASSERT_TRUE(data_ref().buffers.size() > 0); - SPARROW_ASSERT_TRUE(data_ref().length == data_ref().bitmap.size()); + SPARROW_ASSERT_TRUE(static_cast(data_ref().length) == data_ref().bitmap.size()) } template @@ -146,14 +148,14 @@ namespace sparrow auto fixed_size_layout::value(size_type i) -> inner_reference { SPARROW_ASSERT_TRUE(i < size()); - return data()[i + data_ref().offset]; + return data()[i + static_cast(data_ref().offset)]; } template auto fixed_size_layout::value(size_type i) const -> inner_const_reference { SPARROW_ASSERT_TRUE(i < size()); - return data()[i + data_ref().offset]; + return data()[i + static_cast(data_ref().offset)]; } template @@ -210,14 +212,14 @@ namespace sparrow auto fixed_size_layout::has_value(size_type i) -> bitmap_reference { SPARROW_ASSERT_TRUE(i < size()); - return data_ref().bitmap[i + data_ref().offset]; + return data_ref().bitmap[i + static_cast(data_ref().offset)]; } template auto fixed_size_layout::has_value(size_type i) const -> bitmap_const_reference { SPARROW_ASSERT_TRUE(i < size()); - return data_ref().bitmap[i + data_ref().offset]; + return data_ref().bitmap[i + static_cast(data_ref().offset)]; } template @@ -229,7 +231,9 @@ namespace sparrow template auto fixed_size_layout::value_end() -> value_iterator { - return value_begin() + size(); + value_iterator it = value_begin(); + std::advance(it, size()); + return it; } template @@ -241,7 +245,9 @@ namespace sparrow template auto fixed_size_layout::value_cend() const -> const_value_iterator { - return value_cbegin() + size(); + auto it = value_cbegin(); + std::advance(it, size()); + return it; } template @@ -253,7 +259,9 @@ namespace sparrow template auto fixed_size_layout::bitmap_end() -> bitmap_iterator { - return bitmap_begin() + size(); + bitmap_iterator it = bitmap_begin(); + std::advance(it, size()); + return it; } template @@ -265,7 +273,9 @@ namespace sparrow template auto fixed_size_layout::bitmap_cend() const -> const_bitmap_iterator { - return bitmap_cbegin() + size(); + const_bitmap_iterator it = bitmap_cbegin(); + std::advance(it, size()); + return it; } template diff --git a/include/sparrow/mp_utils.hpp b/include/sparrow/mp_utils.hpp index aaf84860..fd829350 100644 --- a/include/sparrow/mp_utils.hpp +++ b/include/sparrow/mp_utils.hpp @@ -172,7 +172,7 @@ namespace sparrow::mpl /// `false` otherwise or if the list is empty. template class L, class... T> requires any_typelist> and (callable_type_predicate && ...) - consteval bool any_of(L list, Predicate predicate = {}) + consteval bool any_of(L , Predicate predicate = {}) { return (evaluate(predicate) || ... || false); } @@ -192,7 +192,7 @@ namespace sparrow::mpl /// or if the list is empty; `false` otherwise. template class L, class... T> requires any_typelist> and (callable_type_predicate && ...) - consteval bool all_of(L list, Predicate predicate) + consteval bool all_of(L, [[maybe_unused]] Predicate predicate) // predicate is used but GCC does not see it, that's why we use [[maybe_unused]] { return (evaluate(predicate) && ... && true); } @@ -219,7 +219,7 @@ namespace sparrow::mpl /// or the size of the list if the matching type was not found. template class L, class... T> requires any_typelist> and (callable_type_predicate && ...) - consteval std::size_t find_if(L list, Predicate predicate) + consteval std::size_t find_if(L, Predicate predicate) { std::size_t idx = 0; auto check = [&](bool match_success) diff --git a/include/sparrow/typed_array.hpp b/include/sparrow/typed_array.hpp index 81436570..44d9a82b 100644 --- a/include/sparrow/typed_array.hpp +++ b/include/sparrow/typed_array.hpp @@ -22,10 +22,11 @@ #include "sparrow/contracts.hpp" #include "sparrow/data_traits.hpp" #include "sparrow/data_type.hpp" + namespace sparrow { template - requires is_arrow_base_type + requires is_arrow_base_type class typed_array; template @@ -37,11 +38,12 @@ namespace sparrow /** * A class template representing a typed array. * - * The `typed_array` class template provides an container interface over `array_data` for elements of a specific type `T`. - * The access to the elements are executed according to the layout `L` of the array. + * The `typed_array` class template provides an container interface over `array_data` for elements of a + * specific type `T`. The access to the elements are executed according to the layout `L` of the array. * * @tparam T The type of elements stored in the array. - * @tparam L The layout type of the array. Defaults to the default layout defined by the `arrow_traits` of `T`. + * @tparam L The layout type of the array. Defaults to the default layout defined by the `arrow_traits` of + * `T`. */ template ::default_layout> requires is_arrow_base_type @@ -146,7 +148,8 @@ namespace sparrow ///@} /* - * @return A range of the bitmap. For each index position in this range, if `true` then there is a value at the same index position in the `values()` range, `false` means the value there is null. + * @return A range of the bitmap. For each index position in this range, if `true` then there is a + * value at the same index position in the `values()` range, `false` means the value there is null. */ const_bitmap_range bitmap() const; @@ -173,9 +176,9 @@ namespace sparrow // TODO: Implement insert, erase, push_back, pop_back, clear, resize, swap - friend std::partial_ordering operator<=>(const typed_array& ta1, const typed_array& ta2); + friend std::partial_ordering operator<=> (const typed_array& ta1, const typed_array& ta2); - friend bool operator==(const typed_array& ta1, const typed_array& ta2); + friend bool operator== (const typed_array& ta1, const typed_array& ta2); private: diff --git a/include/sparrow/variable_size_binary_layout.hpp b/include/sparrow/variable_size_binary_layout.hpp index 4f526fa2..a333ab1d 100644 --- a/include/sparrow/variable_size_binary_layout.hpp +++ b/include/sparrow/variable_size_binary_layout.hpp @@ -316,13 +316,21 @@ namespace sparrow template auto variable_size_binary_layout::has_value(size_type i) const -> bool { - return data_ref().bitmap.test(i + data_ref().offset); + SPARROW_ASSERT_TRUE(data_ref().offset >= 0); + const size_type pos = i + static_cast(data_ref().offset); + return data_ref().bitmap.test(pos); } template auto variable_size_binary_layout::value(size_type i) const -> inner_const_reference { - return inner_const_reference(data(*offset(i)), data(*offset(i + 1))); + const long long offset_i = *offset(i); + SPARROW_ASSERT_TRUE(offset_i >= 0); + const long long offset_next = *offset(i + 1); + SPARROW_ASSERT_TRUE(offset_next >= 0); + const const_data_iterator pointer1 = data(static_cast(offset_i)); + const const_data_iterator pointer2 = data(static_cast(offset_next)); + return inner_const_reference(pointer1, pointer2); } template diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1984f827..3648c186 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -54,6 +54,74 @@ add_executable(${test_target} ${SPARROW_TESTS_SOURCES}) target_link_libraries(${test_target} PRIVATE sparrow doctest::doctest) add_test(NAME ${test_target} COMMAND ${test_target}) +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(compiles_options + /permissive- + /WX # treat warnings as errors + /W4 # Baseline reasonable warnings + # /w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss of data + # /w14254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data + # /w14263 # 'function': member function does not override any base class virtual member function + # /w14265 # 'classname': class has virtual functions, but destructor is not virtual instances of this class may not be destructed correctly + # /w14287 # 'operator': unsigned/negative constant mismatch + # /w14296 # 'operator': expression is always 'boolean_value' + # /w14311 # 'variable': pointer truncation from 'type1' to 'type2' + # /w14545 # expression before comma evaluates to a function which is missing an argument list + # /w14546 # function call before comma missing argument list + # /w14547 # 'operator': operator before comma has no effect; expected operator with side-effect + # /w14549 # 'operator': operator before comma has no effect; did you intend 'operator'? + # /w14555 # expression has no effect; expected expression with side- effect + # /w14619 # pragma warning: there is no warning number 'number' + # /w14640 # Enable warning on thread un-safe static member initialization + # /w14826 # Conversion from 'type1' to 'type_2' is sign-extended. This may cause unexpected runtime behavior. + # /w14905 # wide string literal cast to 'LPSTR' + # /w14906 # string literal cast to 'LPWSTR' + # /w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied + # /we4289 # nonstandard extension used: 'variable': loop control variable declared in the for-loop is used outside the for-loop scope + # /we4244 # conversion from 'type1' to 'type_2', possible loss of data + /Wall # all warnings + /wd4355 # deactivate warning: 'this': used in base member initializer list + /wd4514 # deactivate warning: 'function' : unreferenced inline function has been removed + /wd4625 # deactivate warning: 'derived class' : copy constructor was implicitly defined as deleted because a base class copy constructor is inaccessible or deleted + /wd4626 # deactivate warning: 'derived class' : assignment operator was implicitly defined as deleted because a base class assignment operator is inaccessible or deleted + /wd4710 # deactivate warning: 'function' : function not inlined + /wd4711 # deactivate warning: function 'function' selected for inline expansion + /wd4820 # deactivate warning: 'bytes' bytes padding added after construct 'member_name' + /wd5026 # deactivate warning: 'type': move constructor was implicitly defined as deleted + /wd5027 # deactivate warning: 'type': move assignment operator was implicitly defined as deleted + /wd5045 # deactivate warning: Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified + /external:anglebrackets + /external:W0 + /Zc:__cplusplus) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(compiles_options + -pedantic # Warn on language extensions + -Wall # reasonable and standard + -Wcast-align # warn for potential performance problem casts + -Wconversion # warn on type conversions that may lose data + -Wdouble-promotion # warn if float is implicitly promoted to double + -Werror # treat warnings as errors + -Wextra + -Wformat=2 # warn on security issues around functions that format output (i.e., printf) + -Wimplicit-fallthrough # Warns when case statements fall-through. (Included with -Wextra in GCC, not in clang) + -Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist + -Wnon-virtual-dtor # warn the user if a class with virtual functions has a non-virtual destructor. This helps catch hard to track down memory errors + -Wnull-dereference # warn if a null dereference is detected + -Wold-style-cast # warn for c-style casts + -Woverloaded-virtual # warn if you overload (not override) a virtual function + -Wpedantic # warn if non-standard C++ is used + -Wshadow # warn the user if a variable declaration shadows one from a parent context + -Wsign-conversion # warn on sign conversions + -Wunused # warn on anything being unused + -Wno-c++98-compat + $<$:-Wduplicated-branches> # warn if if / else branches have duplicated code + $<$:-Wduplicated-cond> # warn if if / else chain has duplicated conditions + $<$:-Wlogical-op> # warn about logical operations being used where bitwise were probably wanted + $<$:-Wuseless-cast>) # warn if you perform a cast to the same type +endif() + +target_compile_options(${test_target} PRIVATE ${compiles_options}) + # We do not use non-standard C++ set_target_properties(${test_target} PROPERTIES CMAKE_CXX_EXTENSIONS OFF) target_compile_features(${test_target} PRIVATE cxx_std_20) diff --git a/test/array_data_creation.hpp b/test/array_data_creation.hpp index f115dcd7..5664e06d 100644 --- a/test/array_data_creation.hpp +++ b/test/array_data_creation.hpp @@ -14,6 +14,7 @@ #pragma once +#include #include #include "sparrow/array_data.hpp" @@ -55,8 +56,8 @@ namespace sparrow::test b.data()[i] = static_cast(i); } ad.buffers.push_back(b); - ad.length = n; - ad.offset = offset; + ad.length = static_cast(n); + ad.offset = static_cast(offset); ad.child_data.emplace_back(); return ad; } @@ -98,9 +99,9 @@ namespace sparrow::test }; for (size_t i = 0; i < words.size(); ++i) { - offset_func()[i + 1] = offset_func()[i] + words[i].size(); + offset_func()[i + 1] = offset_func()[i] + static_cast(words[i].size()); std::ranges::copy(words[i], iter); - iter += words[i].size(); + iter += static_cast(words[i].size()); ad.bitmap.set(i, true); } @@ -113,8 +114,8 @@ namespace sparrow::test ad.bitmap.set(i, false); } - ad.length = n; - ad.offset = offset; + ad.length = static_cast(n); + ad.offset = static_cast(offset); return ad; } } \ No newline at end of file diff --git a/test/test_allocator.cpp b/test/test_allocator.cpp index acd0cced..f7f8ca0d 100644 --- a/test/test_allocator.cpp +++ b/test/test_allocator.cpp @@ -78,7 +78,7 @@ TEST_SUITE("any_allocator") a.deallocate(buf, n); } -#if __APPLE__ +#if defined(__APPLE__) // /usr/lib/libc++.1.dylib is missing the symbol __ZNSt3__13pmr20get_default_resourceEv, leading // to an exception at runtime. TEST_CASE_TEMPLATE_INVOKE( diff --git a/test/test_dictionary_encoded_layout.cpp b/test/test_dictionary_encoded_layout.cpp index 385a7161..b62606e7 100644 --- a/test/test_dictionary_encoded_layout.cpp +++ b/test/test_dictionary_encoded_layout.cpp @@ -70,19 +70,19 @@ namespace sparrow for (size_t i = 0; i < words.size(); ++i) { - offset()[i + 1] = offset()[i] + words[i].size(); + offset()[i + 1] = offset()[i] + static_cast(words[i].size()); std::ranges::copy(words[i], iter); - iter += words[i].size(); + iter += static_cast(words[i].size()); dictionary.bitmap.set(i, true); } dictionary.bitmap.set(4, false); - dictionary.length = words.size(); + dictionary.length = static_cast(words.size()); dictionary.offset = 0; return dictionary; } - static constexpr std::array words = {"you", "are", "not", "prepared", "null"}; + static constexpr std::array words{{"you", "are", "not", "prepared", "null"}}; array_data m_data; using sub_layout_type = variable_size_binary_layout; diff --git a/test/test_dynamic_bitset.cpp b/test/test_dynamic_bitset.cpp index 9a856fd3..56528f21 100644 --- a/test/test_dynamic_bitset.cpp +++ b/test/test_dynamic_bitset.cpp @@ -255,8 +255,8 @@ namespace sparrow CHECK_EQ(diff, 2); CHECK_EQ(cdiff, 2); - auto iter_end = b.begin() + b.size(); - auto citer_end = b.cbegin() + b.size(); + auto iter_end = std::next(b.begin(), static_cast(b.size())); + auto citer_end = std::next(b.cbegin(), static_cast(b.size())); CHECK_EQ(iter_end, b.end()); CHECK_EQ(citer_end, b.cend()); }; diff --git a/test/test_fixed_size_layout.cpp b/test/test_fixed_size_layout.cpp index e63bcae5..e3eb81f8 100644 --- a/test/test_fixed_size_layout.cpp +++ b/test/test_fixed_size_layout.cpp @@ -39,8 +39,8 @@ namespace sparrow buffer b(buffer_size); std::iota(b.data(), b.data() + n, -8); ad.buffers.push_back(b); - ad.length = n; - ad.offset = offset; + ad.length = static_cast(n); + ad.offset = static_cast(offset); ad.child_data.push_back(array_data()); return ad; } @@ -58,7 +58,7 @@ namespace sparrow auto buffer_data = ad.buffers[0].data(); for (std::size_t i = 0; i < lt.size(); ++i) { - CHECK_EQ(lt[i].value(), buffer_data[i + ad.offset]); + CHECK_EQ(lt[i].value(), buffer_data[i + static_cast(ad.offset)]); } } @@ -100,7 +100,7 @@ namespace sparrow auto lt_values = lt.values(); for (std::size_t i = 0; i < lt.size(); ++i) { - lt[i] = i; + lt[i] = static_cast(i); } layout_test_type::const_value_iterator citer = lt_values.begin(); diff --git a/test/test_iterator.cpp b/test/test_iterator.cpp index f91fd3fb..5c9c7fb8 100644 --- a/test/test_iterator.cpp +++ b/test/test_iterator.cpp @@ -263,6 +263,11 @@ namespace sparrow const_iterator iter{&(a[0])}; CHECK_EQ(*iter, a[0]); + + iterator iter2{&(a[0])}; + CHECK_EQ(*iter2, a[0]); + *iter2 = 3; + CHECK_EQ(a[0], 3); } } } diff --git a/test/test_typed_array.cpp b/test/test_typed_array.cpp index 16c9af58..7cbff684 100644 --- a/test/test_typed_array.cpp +++ b/test/test_typed_array.cpp @@ -46,7 +46,7 @@ namespace } } - constexpr size_t n = 10; + constexpr size_t array_size = 10; constexpr size_t offset = 1; const std::vector false_bitmap = {9}; } @@ -57,18 +57,16 @@ TEST_SUITE("typed_array") { SUBCASE("constructor with parameter") { - constexpr size_t n = 10; - constexpr size_t offset = 1; - const auto array_data = sparrow::test::make_test_array_data(n, offset); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset); const typed_array ta{array_data}; - CHECK_EQ(ta.size(), n - offset); + CHECK_EQ(ta.size(), array_size - offset); } // Element access SUBCASE("at") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); typed_array ta{array_data}; for (typename typed_array::size_type i = 0; i < ta.size() - 1; ++i) { @@ -81,7 +79,7 @@ TEST_SUITE("typed_array") SUBCASE("const at") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; for (typename typed_array::size_type i = 0; i < ta.size() - 1; ++i) { @@ -94,7 +92,7 @@ TEST_SUITE("typed_array") SUBCASE("operator[]") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); typed_array ta{array_data}; for (typename typed_array::size_type i = 0; i < ta.size() - 1; ++i) { @@ -105,7 +103,7 @@ TEST_SUITE("typed_array") SUBCASE("const operator[]") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; for (typename typed_array::size_type i = 0; i < ta.size() - 1; ++i) { @@ -116,28 +114,28 @@ TEST_SUITE("typed_array") SUBCASE("front") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); typed_array ta{array_data}; CHECK_EQ(ta.front().value(), to_value_type(1)); } SUBCASE("const front") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; CHECK_EQ(ta.front().value(), to_value_type(1)); } SUBCASE("back") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); typed_array ta{array_data}; CHECK_FALSE(ta.back().has_value()); } SUBCASE("const back") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; CHECK_FALSE(ta.back().has_value()); } @@ -146,7 +144,7 @@ TEST_SUITE("typed_array") SUBCASE("const iterators") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; auto iter = ta.cbegin(); @@ -176,12 +174,13 @@ TEST_SUITE("typed_array") SUBCASE("bitmap") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; const auto bitmap = ta.bitmap(); - REQUIRE_EQ(bitmap.size(), n - offset); - for (size_t i = 0; i < bitmap.size() - 1; ++i) + REQUIRE_EQ(bitmap.size(), array_size - offset); + for (int32_t i = 0; i < static_cast(bitmap.size()) -1; ++i) { + CHECK(bitmap[i]); } CHECK_FALSE(bitmap[8]); @@ -189,11 +188,11 @@ TEST_SUITE("typed_array") SUBCASE("values") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; const auto values = ta.values(); - CHECK_EQ(values.size(), n - offset); - for (size_t i = 0; i < values.size(); ++i) + CHECK_EQ(values.size(), array_size - offset); + for (int32_t i = 0; i < static_cast(values.size()); ++i) { CHECK_EQ(values[i], to_value_type(i + 1)); } @@ -203,7 +202,7 @@ TEST_SUITE("typed_array") SUBCASE("empty") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; CHECK_FALSE(ta.empty()); @@ -214,20 +213,20 @@ TEST_SUITE("typed_array") SUBCASE("size") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; - CHECK_EQ(ta.size(), n - offset); + CHECK_EQ(ta.size(), array_size - offset); } // Operators SUBCASE("<=>") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; CHECK_EQ(ta <=> ta, std::strong_ordering::equal); - const auto array_data_less = sparrow::test::make_test_array_data(n - 1, offset - 1, {8}); + const auto array_data_less = sparrow::test::make_test_array_data(array_size - 1, offset - 1, {8}); const typed_array typed_array_less(array_data_less); CHECK_EQ(ta <=> typed_array_less, std::strong_ordering::greater); CHECK_EQ(typed_array_less <=> ta, std::strong_ordering::less); @@ -235,13 +234,13 @@ TEST_SUITE("typed_array") SUBCASE("==") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; const typed_array ta_same{array_data}; CHECK(ta == ta); CHECK(ta == ta_same); - const auto array_data_less = sparrow::test::make_test_array_data(n - 1, offset - 1, {8}); + const auto array_data_less = sparrow::test::make_test_array_data(array_size - 1, offset - 1, {8}); const ::typed_array ta_less{array_data_less}; CHECK_FALSE(ta == ta_less); CHECK_FALSE(ta_less == ta); @@ -249,13 +248,13 @@ TEST_SUITE("typed_array") SUBCASE("!=") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; const typed_array ta_same{array_data}; CHECK_FALSE(ta != ta); CHECK_FALSE(ta != ta_same); - const auto array_data_less = sparrow::test::make_test_array_data(n - 1, offset - 1, {8}); + const auto array_data_less = sparrow::test::make_test_array_data(array_size - 1, offset - 1, {8}); const typed_array ta_less{array_data_less}; CHECK(ta != ta_less); CHECK(ta_less != ta); @@ -263,13 +262,13 @@ TEST_SUITE("typed_array") SUBCASE("<") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; const typed_array ta_same{array_data}; CHECK_FALSE(ta < ta); CHECK_FALSE(ta < ta_same); - const auto array_data_less = sparrow::test::make_test_array_data(n - 1, offset - 1, {8}); + const auto array_data_less = sparrow::test::make_test_array_data(array_size - 1, offset - 1, {8}); const typed_array ta_less{array_data_less}; CHECK_FALSE(ta < ta_less); CHECK(ta_less < ta); @@ -277,13 +276,13 @@ TEST_SUITE("typed_array") SUBCASE(">") { - const auto array_data = sparrow::test::make_test_array_data(n, offset, false_bitmap); + const auto array_data = sparrow::test::make_test_array_data(array_size, offset, false_bitmap); const typed_array ta{array_data}; const typed_array ta_same{array_data}; CHECK_FALSE(ta > ta); CHECK_FALSE(ta > ta_same); - const auto array_data_less = sparrow::test::make_test_array_data(n - 1, offset - 1, {8}); + const auto array_data_less = sparrow::test::make_test_array_data(array_size - 1, offset - 1, {8}); const ::typed_array ta_less{array_data_less}; CHECK(ta > ta_less); CHECK_FALSE(ta_less > ta); diff --git a/test/test_variable_size_binary_layout.cpp b/test/test_variable_size_binary_layout.cpp index 7ae8e0cb..1acf9935 100644 --- a/test/test_variable_size_binary_layout.cpp +++ b/test/test_variable_size_binary_layout.cpp @@ -44,9 +44,9 @@ namespace sparrow auto iter = m_data.buffers[1].begin(); for (size_t i = 0; i < nb_words; ++i) { - offset()[i + 1] = offset()[i] + words[i].size(); - std::copy(words[i].cbegin(), words[i].cend(), iter); - iter += words[i].size(); + offset()[i + 1] = static_cast(static_cast(offset()[i]) + words[i].size()); + std::ranges::copy(words[i], iter); + iter += static_cast(words[i].size()); m_data.bitmap.set(i, true); } @@ -101,7 +101,6 @@ namespace sparrow { layout_type l(m_data); auto cref0 = l[0]; - auto cref1 = l[1]; auto cref2 = l[2]; auto vrange = l.values(); @@ -132,7 +131,6 @@ namespace sparrow { layout_type l(m_data); auto cref0 = l[0]; - auto cref1 = l[1]; auto cref2 = l[2]; auto iter = l.cbegin();