Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't check equality of shapes of xtensor_fixed and xscalar #2789

Open
tailsu opened this issue May 27, 2024 · 0 comments
Open

Can't check equality of shapes of xtensor_fixed and xscalar #2789

tailsu opened this issue May 27, 2024 · 0 comments

Comments

@tailsu
Copy link

tailsu commented May 27, 2024

Tested on 0.25.0, Clang 17. Repro code below. Code works when XTENSOR_ENABLE_ASSERT is not defined and doesn't compile when it is defined.

// #define XTENSOR_ENABLE_ASSERT

#include <xtensor/xfixed.hpp>
#include <xtensor/xscalar.hpp>
#include <iostream>

using Point2i = xt::xtensor_fixed<int, xt::xshape<2>>;

int main() {
    Point2i bits{3, 4};
    bool valid = xt::all(bits <= 100);

    std::cout << valid << std::endl;
    return 0;
}

The compiler says it can't equality-compare xtensor_fixed::shape() and xscalar::shape(). The former is an xt::const_array and the latter is an std::array, so maybe that's why.

xtensor/xiterator.hpp:1199:38: error: invalid operands to binary expression ('const xt::fixed_shape<2>' and 'const xt::fixed_shape<2>')
        XTENSOR_ASSERT(this->shape() == rhs.shape());
                       ~~~~~~~~~~~~~ ^  ~~~~~~~~~~~
xtensor/xexception.hpp:331:50: note: expanded from macro 'XTENSOR_ASSERT'
#define XTENSOR_ASSERT(expr) XTENSOR_ASSERT_IMPL(expr, __FILE__, __LINE__)
                                                 ^~~~
xtensor/xexception.hpp:333:11: note: expanded from macro 'XTENSOR_ASSERT_IMPL'
    if (!(expr))                                                                                   \
          ^~~~
xtensor/xiterator.hpp:1213:20: note: in instantiation of member function 'xt::xiterator<xt::xfunction_stepper<xt::detail::less_equal, const xt::xfixed_container<int, xt::fixed_shape<2>, xt::layout_type::row_major> &, xt::xscalar<int>>, xt::fixed_shape<2> *, xt::layout_type::row_major>::equal' requested here
        return lhs.equal(rhs);

This used to compile fine somewhere around version 0.23.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant