<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/91504>91504</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Ambiguous Template Specialization with Xtensor
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jtramm
</td>
</tr>
</table>
<pre>
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`:
```C++
#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 1c683eb324aea08b2f9de26cac27532da8a0f7e3, but was broken somewhere between 1c683eb324aea08b2f9de26cac27532da8a0f7e3 and 05f4448d40f00b9fb2447e1c32cd18a7a9b8b011.
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
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsXEtzo7oS_jXKRpUUSGDDwovEiaum6py7mal7z84loLE1EYgriWTmLu5vPyVhMGDnMZm8fAqXK8E8pO7v6251t8FMa74pARYovELh9RmrzVaqxXejWFGcJTL7ufgqCzC8AMxLbLaABdMGF7I0W8zKDDO8ZSLHUmEtEVniP_749594yzROlLyFEudSucuWiFwhcoV_GCi1VHgLLAOFBU8UUz8xItHWmEojeonICpHVhpttnVykskBktbvoXBuW3u4_IxJfIO8aeZfN3y94y-4AM1zwkhdMYAWVklmdgrKioZlXMF5epFWFZp6dqXet3ePeO0F3ewnlZSrqDDAipJt29YMpxX5ebKsKEdIfhpcG20kQie4kzxCJMZrvBsP4h7Gz0svmckSXmawTAYjeYANFhWh3pgJTqxJ73S40vx4J2p82lUXFBWSY6Yf02p0oWLnZUdGCgc-_ILKqmNkisjKyj--q1f7IKWJ_-BHJvhh8L9WtxjkvAd9zs8VC3BXYjy78C8_SYq2orrCR2E9nEYWEkoAB86KE5HEGZJaylMxDSjIWMS-fA7VXJbXB93sz07KA-y0owAmYe4Dy2YO5-b0wD4IgygIv97wkzhMSBHPwU0rSzI_YnMVJlHi-PzC3_1hlrG2ntVJQGpzBHQhZ4TtQmssSy9y5gxWXG7zhd6Dd-bkUQt7zcoNBKaleythWFoDIqnFWRFaygrJI1zLPhWRZtwOR1R2UWWO3x4l90UgH_H8pcc6FDRRuZ4ZzJYtOZkQv_U7T46e-kk6DfT1PpZd-_BESJHWeg1qzjFVGqp0o5EPA0EYqtoFWBvoRMjRba82LrKVlvneBt5ixNlzo3VxRPEP0klr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