From 9c68fbdc070f08b78333ae8310f64d01e3fd88be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Thu, 1 Aug 2024 16:24:45 +0200 Subject: [PATCH] Fix various compiler warnings These solve warnings when compiled with gcc 14 using a set of warnings enabled that we use in one of our projects: -Wall -Wnon-virtual-dtor -Wzero-as-null-pointer-constant -Wduplicated-branches -Wundef -Wvla -Wpointer-arith -Wextra -Wno-unused-parameter --- include/xtensor/xassign.hpp | 25 +++++++++++++++---------- include/xtensor/xfixed.hpp | 2 +- include/xtensor/xsort.hpp | 2 -- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/xtensor/xassign.hpp b/include/xtensor/xassign.hpp index 2ec698ae6..6d3d02cf7 100644 --- a/include/xtensor/xassign.hpp +++ b/include/xtensor/xassign.hpp @@ -456,16 +456,21 @@ namespace xt constexpr bool simd_strided_assign = traits::simd_strided_assign(); if (linear_assign) { - if (simd_linear_assign || traits::simd_linear_assign(de1, de2)) - { - // Do not use linear_assigner here since it will make the compiler - // instantiate this branch even if the runtime condition is false, resulting - // in compilation error for expressions that do not provide a SIMD interface. - // simd_assign is true if simd_linear_assign() or simd_linear_assign(de1, de2) - // is true. - linear_assigner::run(de1, de2); - } - else + // Do not use linear_assigner here since it will make the compiler + // instantiate this branch even if the runtime condition is false, resulting + // in compilation error for expressions that do not provide a SIMD interface. + // simd_assign is true if simd_linear_assign() or simd_linear_assign(de1, de2) + // is true. + if constexpr(simd_assign) { + if(simd_linear_assign || traits::simd_linear_assign(de1, de2)) + { + linear_assigner::run(de1, de2); + } + else + { + linear_assigner::run(de1, de2); + } + } else { linear_assigner::run(de1, de2); } diff --git a/include/xtensor/xfixed.hpp b/include/xtensor/xfixed.hpp index c6ba964ed..36e9910d3 100644 --- a/include/xtensor/xfixed.hpp +++ b/include/xtensor/xfixed.hpp @@ -153,7 +153,7 @@ namespace xt (L == layout_type::row_major) || (L == layout_type::column_major), "Layout not supported for fixed array" ); -#if (_MSC_VER >= 1910) +#if (defined(_MSC_VER_) && _MSC_VER >= 1910) using temp_type = std::index_sequence; return R({workaround::get_computed_strides(shape[I] == 1)...}); #else diff --git a/include/xtensor/xsort.hpp b/include/xtensor/xsort.hpp index 95591a798..a539c7dc9 100644 --- a/include/xtensor/xsort.hpp +++ b/include/xtensor/xsort.hpp @@ -1242,7 +1242,6 @@ namespace xt template inline auto argmin(const xexpression& e) { - using value_type = typename E::value_type; auto&& ed = eval(e.derived_cast()); auto begin = ed.template begin(); auto end = ed.template end(); @@ -1272,7 +1271,6 @@ namespace xt template inline auto argmax(const xexpression& e) { - using value_type = typename E::value_type; auto&& ed = eval(e.derived_cast()); auto begin = ed.template begin(); auto end = ed.template end();