Skip to content

Commit

Permalink
Fix various compiler warnings
Browse files Browse the repository at this point in the history
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
  • Loading branch information
aroffringa committed Aug 1, 2024
1 parent 8c0a484 commit 329d5ee
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
25 changes: 15 additions & 10 deletions include/xtensor/xassign.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<true> 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<simd_assign>::run(de1, de2);
}
else
// Do not use linear_assigner<true> 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<true>::run(de1, de2);
}
else
{
linear_assigner<false>::run(de1, de2);
}
} else
{
linear_assigner<false>::run(de1, de2);
}
Expand Down
2 changes: 1 addition & 1 deletion include/xtensor/xfixed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<X...>;
return R({workaround::get_computed_strides<L, I, temp_type>(shape[I] == 1)...});
#else
Expand Down
2 changes: 1 addition & 1 deletion include/xtensor/xmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ namespace xt
#define XTENSOR_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)

// Workaround for MSVC 2015 & GCC 4.9
#if (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__GNUC__) && GCC_VERSION < 49999)
#if (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__GNUC__) && XTENSOR_GCC_VERSION < 49999)
#define XTENSOR_DISABLE_LAMBDA_FCT
#endif

Expand Down
2 changes: 0 additions & 2 deletions include/xtensor/xsort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,6 @@ namespace xt
template <layout_type L = XTENSOR_DEFAULT_TRAVERSAL, class E>
inline auto argmin(const xexpression<E>& e)
{
using value_type = typename E::value_type;
auto&& ed = eval(e.derived_cast());
auto begin = ed.template begin<L>();
auto end = ed.template end<L>();
Expand Down Expand Up @@ -1272,7 +1271,6 @@ namespace xt
template <layout_type L = XTENSOR_DEFAULT_TRAVERSAL, class E>
inline auto argmax(const xexpression<E>& e)
{
using value_type = typename E::value_type;
auto&& ed = eval(e.derived_cast());
auto begin = ed.template begin<L>();
auto end = ed.template end<L>();
Expand Down
2 changes: 1 addition & 1 deletion include/xtensor/xutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "xtensor_config.hpp"

#if (_MSC_VER >= 1910)
#if (defined(_MSC_VER) && _MSC_VER >= 1910)
#define NOEXCEPT(T)
#else
#define NOEXCEPT(T) noexcept(T)
Expand Down

0 comments on commit 329d5ee

Please sign in to comment.