Skip to content

Bug in sort #262

Description

@tdegeus

The following code

#include <xtensor.hpp>
#include <pybind11/pybind11.h>

namespace py = pybind11;

#define FORCE_IMPORT_ARRAY
#include <xtensor-python/pyarray.hpp>
#include <xtensor-python/pytensor.hpp>

template <class T>
inline auto foo(const T& arg)
{
    return xt::sort(arg);
}

PYBIND11_MODULE(mymodule, m)
{
    xt::import_numpy();
    m.doc() = "Module description";
    m.def("foo", &foo<xt::pytensor<size_t, 1>>, "Function description", py::arg("arg"));
}

Gives:

...\include\xtensor\xsort.hpp(155,31): error C2397: conversion from 'unsigned __int64' to '_Ty' requires a narrowing conversion with
          [
              _Ty=ptrdiff_t
          ]
...\include\xtensor\xsort.hpp(204): message : see reference to function template instantiation 'auto xt::detail::flat_sort_impl<xt::pytensor<size_t,1,xt::layout_type::dynamic>,eval_type>(const xt::xexpression<D> &)' being compiled with
          [
              D=xt::pytensor<size_t,1,xt::layout_type::dynamic>
          ]
...\main.cpp(13): message : see reference to function template instantiation 'auto xt::sort<D>(const xt::xexpression<D> &,ptrdiff_t)' being compiled with
          [
              D=xt::pytensor<size_t,1,xt::layout_type::dynamic>
          ]
...\main.cpp(20): message : see reference to function template instantiation 'auto foo<xt::pytensor<size_t,1,xt::layout_type::dynamic>>(const T &)' being compiled with
          [
              T=xt::pytensor<size_t,1,xt::layout_type::dynamic>
          ]

on Windows. It works fine on macOS, and gives a very vague error message on Linux.

For full CI, see tdegeus/xtensor-python_examples#1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions