[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)
via cfe-commits
cfe-commits at lists.llvm.org
Tue May 7 11:07:41 PDT 2024
eaeltsin wrote:
Hi, is there a way to make a compile-time check for this feature?
Looking at
1. https://github.com/xtensor-stack/xtensor/blob/master/include/xtensor/xutils.hpp#L1029
2. https://github.com/xtensor-stack/xtensor/blob/master/include/xtensor/xstorage.hpp#L1415
After this commit, 2 becomes ambiguous. If 2 is deleted, the code doesn't compile before this commit.
Or am I wrong and this code has another problem?
Output after the commit:
```
n file included from xtensor/xexpression_holder.hpp:17:
In file included from xtensor/xarray.hpp:19:
In file included from xtensor/xbuffer_adaptor.hpp:21:
In file included from xtensor/xstorage.hpp:23:
In file included from xtensor/xtensor_simd.hpp:17:
ERROR: xtensor/xutils.hpp:899:31 ambiguous partial specializations of 'rebind_container<long, xt::svector<unsigned long>>'
899 | using type = typename rebind_container<std::ptrdiff_t, S>::type;
| ^
xtensor/xutils.hpp:927:5 in instantiation of template class 'xt::get_strides_type<xt::svector<unsigned long>>' requested here
927 | using get_strides_t = typename get_strides_type<C>::type;
| ^
xtensor/xarray.hpp:53:30 in instantiation of template type alias 'get_strides_t' requested here
53 | using strides_type = get_strides_t<shape_type>;
| ^
xtensor/xcontainer.hpp:36:43 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;
| ^
xtensor/xarray.hpp:64:11 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>>
| ^
xtensor/xiterable.hpp:43:43 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;
| ^
xtensor/xiterable.hpp:151:30 (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 to see all)
151 | class xiterable : public xconst_iterable<D>
| ^
xtensor/xiterable.hpp:311:42 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>
| ^
xtensor/xcontainer.hpp:71:31 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>,
| ^
xtensor/xcontainer.hpp:260:39 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>
| ^
xtensor/xarray.hpp:82:37 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>>,
| ^
xtensor/xexpression_holder.hpp:192:32 in instantiation of template class 'xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>' requested here
192 | xt::xarray<double> empty_arr;
| ^
xtensor/xutils.hpp:886:12 partial specialization matches [with X = long, C = xt::svector, T = unsigned long, N = 4]
886 | struct rebind_container<X, C<T, N>>
| ^
xtensor/xstorage.hpp:1415:12 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>>
| ^
```
Output before the commit if the second specialization is deleted:
```
In file included from xtensor/test/test_extended_broadcast_view.cpp:15:
In file included from xtensor/xarray.hpp:19:
In file included from xtensor/xbuffer_adaptor.hpp:21:
In file included from xtensor/xstorage.hpp:23:
In file included from xtensor/xtensor_simd.hpp:17:
xtensor/xutils.hpp:899:31: error: implicit instantiation of undefined template 'xt::rebind_container<long, xt::svector<unsigned long>>'
899 | using type = typename rebind_container<std::ptrdiff_t, S>::type;
| ^
xtensor/xutils.hpp:927:5: note: in instantiation of template class 'xt::get_strides_type<xt::svector<unsigned long>>' requested here
927 | using get_strides_t = typename get_strides_type<C>::type;
| ^
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>;
| ^
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;
| ^
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>>
| ^
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;
| ^
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>
| ^
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>
| ^
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>,
| ^
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>
| ^
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>>,
| ^
xtensor/test/test_extended_broadcast_view.cpp:34:24: note: in instantiation of template class 'xt::xarray_container<xt::uvector<double>, xt::layout_type::row_major, xt::svector<unsigned long>>' requested here
34 | xarray<double> py_a = {
| ^
xtensor/xutils.hpp:79:12: note: template is declared here
79 | struct rebind_container;
| ^
```
https://github.com/llvm/llvm-project/pull/89807
More information about the cfe-commits
mailing list