Skip to content

Ambiguous Template Specialization with Xtensor #91504

Closed
@jtramm

Description

@jtramm

Sometime in the last month and a half or so, LLVM has broken for the C++ xtensor header library (https://github.com/xtensor-stack/xtensor).

I have a minimal reproducer, main.cpp:

#include "xtensor/xarray.hpp"

int main(void) {
  xt::xarray<double> temp;
  return 0;
}

compiled as:

clang++ main.cpp -I/path/to/xtensor/include -I/path/to/xtl/include

It works fine with llvm 18.1.0, and up to 1c683eb, but was broken somewhere between 1c683eb and 05f4448.

With the current develop version of LLVM, it gives the following error:

clang++ main.cpp -I/home/jtramm/openmc_offload/openmc/vendor/xtensor/include -I/home/jtramm/openmc_offload/openmc/vendor/xtl/include
In file included from main.cpp:1:
In file included from /home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xarray.hpp:19:
In file included from /home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xbuffer_adaptor.hpp:21:
In file included from /home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xstorage.hpp:23:
In file included from /home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xtensor_simd.hpp:17:
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xutils.hpp:896:31: error: ambiguous partial specializations of 'rebind_container<long, xt::svector<unsigned long>>'
  896 |         using type = typename rebind_container<std::ptrdiff_t, S>::type;
      |                               ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xutils.hpp:924:5: note: in instantiation of template class 'xt::get_strides_type<xt::svector<unsigned long>>' requested here
  924 |     using get_strides_t = typename get_strides_type<C>::type;
      |     ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xarray.hpp:53:30: note: in instantiation of template type alias 'get_strides_t' requested here
   53 |         using strides_type = get_strides_t<shape_type>;
      |                              ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:36:43: note: in instantiation of template class 'xt::xcontainer_inner_types<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
   36 |         using inner_shape_type = typename xcontainer_inner_types<D>::inner_shape_type;
      |                                           ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xarray.hpp:64:11: note: in instantiation of template class 'xt::xcontainer_iterable_types<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
   64 |         : xcontainer_iterable_types<xarray_container<EC, L, SC, Tag>>
      |           ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xiterable.hpp:43:43: note: in instantiation of template class 'xt::xiterable_inner_types<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
   43 |         using inner_shape_type = typename iterable_types::inner_shape_type;
      |                                           ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xiterable.hpp:151:30: note: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 to see all)
  151 |     class xiterable : public xconst_iterable<D>
      |                              ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xiterable.hpp:311:42: note: in instantiation of template class 'xt::xiterable<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
  311 |     class xcontiguous_iterable : private xiterable<D>
      |                                          ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:71:31: note: in instantiation of template class 'xt::xcontiguous_iterable<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
   71 |     class xcontainer : public xcontiguous_iterable<D>,
      |                               ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:260:39: note: in instantiation of template class 'xt::xcontainer<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
  260 |     class xstrided_container : public xcontainer<D>
      |                                       ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xarray.hpp:82:37: note: in instantiation of template class 'xt::xstrided_container<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
   82 |     class xarray_container : public xstrided_container<xarray_container<EC, L, SC, Tag>>,
      |                                     ^
main.cpp:4:22: note: in instantiation of template class 'xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>' requested here
    4 |   xt::xarray<double> temp;
      |                      ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xutils.hpp:883:12: note: partial specialization matches [with X = long, C = xt::svector, T = unsigned long, N = 4]
  883 |     struct rebind_container<X, C<T, N>>
      |            ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xstorage.hpp:1415:12: note: partial specialization matches [with X = long, T = unsigned long, N = 4, A = std::allocator<unsigned long>, B = true]
 1415 |     struct rebind_container<X, svector<T, N, A, B>>
      |            ^
In file included from main.cpp:1:
In file included from /home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xarray.hpp:20:
In file included from /home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:23:
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xiterable.hpp:45:50: error: no type named 'stepper' in 'xt::xiterable_inner_types<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>'
   45 |         using stepper = typename iterable_types::stepper;
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xiterable.hpp:151:30: note: in instantiation of template class 'xt::xconst_iterable<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
  151 |     class xiterable : public xconst_iterable<D>
      |                              ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xiterable.hpp:311:42: note: in instantiation of template class 'xt::xiterable<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
  311 |     class xcontiguous_iterable : private xiterable<D>
      |                                          ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:71:31: note: in instantiation of template class 'xt::xcontiguous_iterable<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
   71 |     class xcontainer : public xcontiguous_iterable<D>,
      |                               ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:260:39: note: in instantiation of template class 'xt::xcontainer<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
  260 |     class xstrided_container : public xcontainer<D>
      |                                       ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xarray.hpp:82:37: note: in instantiation of template class 'xt::xstrided_container<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
   82 |     class xarray_container : public xstrided_container<xarray_container<EC, L, SC, Tag>>,
      |                                     ^
main.cpp:4:22: note: in instantiation of template class 'xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>' requested here
    4 |   xt::xarray<double> temp;
      |                      ^
In file included from main.cpp:1:
In file included from /home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xarray.hpp:20:
In file included from /home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:23:
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xiterable.hpp:46:56: error: no type named 'const_stepper' in 'xt::xiterable_inner_types<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>'
   46 |         using const_stepper = typename iterable_types::const_stepper;
      |                               ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
In file included from main.cpp:1:
In file included from /home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xarray.hpp:20:
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:140:15: error: using declaration refers into 'accessible_base::', which is not a base class of 'xcontainer<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>'
  140 |         using accessible_base::at;
      |               ^~~~~~~~~~~~~~~~~
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:260:39: note: in instantiation of template class 'xt::xcontainer<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
  260 |     class xstrided_container : public xcontainer<D>
      |                                       ^
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xarray.hpp:82:37: note: in instantiation of template class 'xt::xstrided_container<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>' requested here
   82 |     class xarray_container : public xstrided_container<xarray_container<EC, L, SC, Tag>>,
      |                                     ^
main.cpp:4:22: note: in instantiation of template class 'xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>' requested here
    4 |   xt::xarray<double> temp;
      |                      ^
In file included from main.cpp:1:
In file included from /home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xarray.hpp:20:
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:141:15: error: using declaration refers into 'accessible_base::', which is not a base class of 'xcontainer<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>'
  141 |         using accessible_base::shape;
      |               ^~~~~~~~~~~~~~~~~
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:142:15: error: using declaration refers into 'accessible_base::', which is not a base class of 'xcontainer<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>'
  142 |         using accessible_base::operator[];
      |               ^~~~~~~~~~~~~~~~~
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:143:15: error: using declaration refers into 'accessible_base::', which is not a base class of 'xcontainer<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>'
  143 |         using accessible_base::back;
      |               ^~~~~~~~~~~~~~~~~
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:144:15: error: using declaration refers into 'accessible_base::', which is not a base class of 'xcontainer<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>'
  144 |         using accessible_base::front;
      |               ^~~~~~~~~~~~~~~~~
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:145:15: error: using declaration refers into 'accessible_base::', which is not a base class of 'xcontainer<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>'
  145 |         using accessible_base::in_bounds;
      |               ^~~~~~~~~~~~~~~~~
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xcontainer.hpp:146:15: error: using declaration refers into 'accessible_base::', which is not a base class of 'xcontainer<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>'
  146 |         using accessible_base::periodic;
      |               ^~~~~~~~~~~~~~~~~
In file included from main.cpp:1:
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xarray.hpp:93:52: error: no type named 'allocator_type' in 'xt::xstrided_container<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>'
   93 |         using allocator_type = typename base_type::allocator_type;
      |                                ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
main.cpp:4:22: note: in instantiation of template class 'xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>' requested here
    4 |   xt::xarray<double> temp;
      |                      ^
In file included from main.cpp:1:
/home/jtramm/openmc_offload/openmc/vendor/xtensor/include/xtensor/xarray.hpp:102:54: error: no type named 'backstrides_type' in 'xt::xstrided_container<xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>>'
  102 |         using backstrides_type = typename base_type::backstrides_type;
      |                                  ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
12 errors generated.
make: *** [Makefile:2: all] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"needs-reductionLarge reproducer that should be reduced into a simpler form

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions