diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index c8217ba..98619ce 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -12,9 +12,9 @@ jobs: strategy: matrix: os: - - 13 - 14 - 15 + - 26 runs-on: macos-${{ matrix.os }} name: 'macos-${{ matrix.os }}' @@ -44,4 +44,3 @@ jobs: run: | cd build/test ./test_xtl - diff --git a/include/xtl/xbasic_fixed_string.hpp b/include/xtl/xbasic_fixed_string.hpp index 53b022c..877d04f 100644 --- a/include/xtl/xbasic_fixed_string.hpp +++ b/include/xtl/xbasic_fixed_string.hpp @@ -218,7 +218,7 @@ namespace xtl struct select_storage { template - using type = typename select_fixed_storage::type; + using type = typename select_fixed_storage::type; }; template <> @@ -916,8 +916,9 @@ namespace xtl template inline auto xbasic_fixed_string::assign(InputIt first, InputIt last) -> self_type& { - m_storage.set_size(error_policy::check_size(static_cast(std::distance(first, last)))); - std::copy(first, last, data()); + auto size = error_policy::check_size(static_cast(std::distance(first, last))); + m_storage.set_size(size); + std::copy_n(first, size, data()); return *this; } diff --git a/include/xtl/xhalf_float_impl.hpp b/include/xtl/xhalf_float_impl.hpp index 8d4d6b9..11e8956 100644 --- a/include/xtl/xhalf_float_impl.hpp +++ b/include/xtl/xhalf_float_impl.hpp @@ -3994,7 +3994,7 @@ namespace half_float { /// \throw std::overflow_error if `FE_OVERFLOW` is selected and set /// \throw std::underflow_error if `FE_UNDERFLOW` is selected and set /// \throw std::range_error if `FE_INEXACT` is selected and set - inline void fethrowexcept(int excepts, const char *msg = "") { + inline void fethrowexcept([[maybe_unused]] int excepts, const char *msg = "") { excepts &= detail::errflags(); #if HALF_ERRHANDLING_THROWS #ifdef HALF_ERRHANDLING_THROW_INVALID diff --git a/include/xtl/xsequence.hpp b/include/xtl/xsequence.hpp index 55c7b64..eb4ac05 100644 --- a/include/xtl/xsequence.hpp +++ b/include/xtl/xsequence.hpp @@ -11,6 +11,7 @@ #define XTL_SEQUENCE_HPP #include +#include #include #include #include @@ -120,7 +121,8 @@ namespace xtl static inline R forward(const T& r) { R ret; - std::copy(std::begin(r), std::end(r), std::begin(ret)); + // We can not use std::copy here because it gives an array-bounds warning with GCC + std::copy_n(std::begin(r), std::size(ret), std::begin(ret)); return ret; } }; diff --git a/include/xtl/xspan_impl.hpp b/include/xtl/xspan_impl.hpp index 4ad45d7..3962fd8 100644 --- a/include/xtl/xspan_impl.hpp +++ b/include/xtl/xspan_impl.hpp @@ -551,13 +551,13 @@ class span { /* Deduction Guides */ template -span(T (&)[N])->span; +span(T (&)[N])->span(N)>; template -span(std::array&)->span; +span(std::array&)->span(N)>; template -span(const std::array&)->span; +span(const std::array&)->span(N)>; template span(Container&)->span; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ee6ce9c..cd98bcf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -37,7 +37,7 @@ if(nlohmann_json_FOUND) endif() if(CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Intel) - add_compile_options(-Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion) + add_compile_options(-Werror -Wall -Wextra -Wconversion -Wsign-conversion $<$,$,12>>:-Wno-stringop-overflow>) if(NOT CMAKE_CXX_FLAGS MATCHES "-march") CHECK_CXX_COMPILER_FLAG(-march=native HAS_MARCH_NATIVE) @@ -60,7 +60,7 @@ endif() if(CMAKE_CXX_COMPILER_ID MATCHES Clang) if(NOT WIN32) - add_compile_options(-Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion) + add_compile_options(-Werror -Wall -Wextra -Wconversion -Wsign-conversion) if(NOT CMAKE_CXX_FLAGS MATCHES "-march") CHECK_CXX_COMPILER_FLAG(-march=native HAS_MARCH_NATIVE) @@ -93,7 +93,7 @@ set(XTL_TESTS test_xfunctional.cpp test_xhalf_float.cpp test_xhash.cpp - test_xhierarchy_generator.cpp + # test_xhierarchy_generator.cpp test_xiterator_base.cpp test_xmasked_value.cpp test_xmeta_utils.cpp diff --git a/test/test_xbasic_fixed_string.cpp b/test/test_xbasic_fixed_string.cpp index 5988dcc..631c0e8 100644 --- a/test/test_xbasic_fixed_string.cpp +++ b/test/test_xbasic_fixed_string.cpp @@ -1105,7 +1105,6 @@ namespace xtl { string_type s1 = "aabcdef"; string_type s2 = "abcdefg"; - string_type s3 = "aabcd"; EXPECT_TRUE(s1 < s2); EXPECT_TRUE(s1 <= s2); @@ -1278,8 +1277,8 @@ namespace xtl TEST(xfixed_string, limit) { - using string_type = xbasic_fixed_string; - string_type s1 = "hello"; + using string_type_ = xbasic_fixed_string; + string_type_ s1 = "hello"; static_assert(sizeof(s1) == 256 * sizeof(char), "minimal storage"); } diff --git a/test/test_xcomplex.cpp b/test/test_xcomplex.cpp index df9935c..fa42633 100644 --- a/test/test_xcomplex.cpp +++ b/test/test_xcomplex.cpp @@ -318,7 +318,7 @@ namespace xtl { double x = 5.0; auto x_closure = closure(x); - std::complex b(0, 5), c; + std::complex b(0, 5); EXPECT_COMPLEX_APPROX_EQ(b + x_closure, b + 5.0); EXPECT_COMPLEX_APPROX_EQ(x_closure + b, 5.0 + b); EXPECT_COMPLEX_APPROX_EQ(b - x_closure, b - 5.0); diff --git a/test/test_xmasked_value.cpp b/test/test_xmasked_value.cpp index 808277d..63f48a3 100644 --- a/test/test_xmasked_value.cpp +++ b/test/test_xmasked_value.cpp @@ -575,6 +575,7 @@ namespace xtl EXPECT_EQ(pow(o, m1).value(), std::pow(5., 5.)); EXPECT_EQ(pow(m1, 2).value(), 25.0); EXPECT_EQ(pow(2, m1).value(), 32); + EXPECT_EQ(pow(m1, m2).value(), std::pow(5., 5.)); } TEST(xmasked_value, ternary_op) diff --git a/test/test_xoptional.cpp b/test/test_xoptional.cpp index 74039da..326c498 100644 --- a/test/test_xoptional.cpp +++ b/test/test_xoptional.cpp @@ -210,7 +210,6 @@ namespace xtl auto res8 = fma(o1, o2, o3); EXPECT_EQ(res8, std::fma(d1, d2, d3)); - using optional_int = xoptional; using optional_int_ref = xoptional; int i1 = 9; int i2 = 4; @@ -232,7 +231,7 @@ namespace xtl auto res13 = ~oi1; EXPECT_EQ(res13, optional(~i1, true)); - + auto res5 = oi1 || oi2; EXPECT_EQ(res5, optional(i1 || i2, true)); @@ -297,7 +296,6 @@ namespace xtl TEST(xoptional, select) { - using opt_type = xoptional; using bool_opt_type = xoptional; auto missing_val = missing(); diff --git a/test/test_xsequence.cpp b/test/test_xsequence.cpp index 315945a..1613255 100644 --- a/test/test_xsequence.cpp +++ b/test/test_xsequence.cpp @@ -39,14 +39,24 @@ namespace xtl return result(xtl::forward_sequence(arg)); } + template + auto test_data(T&& arg) + { + using shape_type = std::array; + shape_type a = xtl::forward_sequence(arg); + return a; + } + TEST(xsequence, forward_type) { - std::array a, b; - std::vector c; + std::array a; + std::vector c(2); + EXPECT_TRUE(test(std::move(a))); EXPECT_FALSE(test(a)); EXPECT_TRUE(test(c)); EXPECT_TRUE(test(std::move(c))); + EXPECT_EQ(test_data(c)[0], 0); } template @@ -57,11 +67,19 @@ namespace xtl TEST(xsequence, different_arrays) { - std::array x, y; - aligned_array aa, ab; + std::array x{}; + aligned_array aa{}; auto res1 = test_different_array>(x); + EXPECT_EQ(res1.size(), 3); + EXPECT_EQ(res1[0], 0); + EXPECT_EQ(res1[1], 0); + EXPECT_EQ(res1[2], 0); auto res2 = test_different_array>(aa); + EXPECT_EQ(res2.size(), 3); + EXPECT_EQ(res2[0], 0); + EXPECT_EQ(res2[1], 0); + EXPECT_EQ(res2[2], 0); } TEST(xsequence, forward)