Created attachment 48554 [details] gcc 10 don't compile but clang compile gcc 10.1 -O3 -std=c++2a -fconcepts -fanalyzer clang10 compile https://godbolt.org/z/Y_iYcQ
gcc 9.3 compile
Comment on attachment 48554 [details] gcc 10 don't compile but clang compile >#include <array> > >namespace math { > > template <typename T, std::size_t Row, std::size_t Col> > requires std::is_arithmetic_v<T> > class matrix { > union { > std::array<T, Row * Col> m_elements_1d; > std::array<std::array<T, Col>, Row> m_elements_2d; > }; > > public: > template <typename ...Args> > requires > std::conjunction_v<std::is_same<T, Args>...> > constexpr matrix(const Args&... args) noexcept > : m_elements_1d {{ args... }} {} > > template <typename ...Args> > requires > std::conjunction_v<std::is_same<std::array<T, Col>, Args>...> > constexpr matrix(const Args&... args) noexcept > : m_elements_2d {{ args... }} {} > }; >} > >#include <iostream> > >template <typename T> >void test() { > > T f1, f2, f3, f4, f5, f6, f7, f8; > > std::cin >> f1 >> f2 >> f3 >> f4 >> f5 >> f6 >> f7 >> f8; > math::matrix<T, 4, 4> m0( > std::array<T, 4> {{ f1, f2, f3, f4 }}, > std::array<T, 4> {{ f5, f6, f7, f8 }} > ); >} > >int main(int argc, char **argv) >{ > test<float>(); > return 0; >}
Reduced test-case: $ cat pr95181.ii template <typename> bool a; template <typename, typename> struct b; template <typename, long> struct array; template <typename d, int c> class f { template <typename... e> f(const e &...); template <typename... e> requires a<b<array<d, c>, e>...> f(const e &...); }; started with r10-3735-gcb57504a55015891.
Another testcase: template <typename> class f { template <typename> f(); template <typename> requires false f(); };
I will look into this.
Unassigning myself due to the issue described in https://gcc.gnu.org/pipermail/gcc-patches/2020-May/546308.html which my initial patch attempt fails to address.
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>: https://gcc.gnu.org/g:c75ebe76ae12ac4020f20a24f34606a594a40d15 commit r11-735-gc75ebe76ae12ac4020f20a24f34606a594a40d15 Author: Patrick Palka <ppalka@redhat.com> Date: Fri May 22 10:28:19 2020 -0400 c++: P0848R3 and member function templates [PR95181] When comparing two special member function templates to see if one hides the other (as per P0848R3), we need to check satisfaction which we can't do on templates. So this patch makes add_method skip the eligibility test on member function templates and just lets them coexist. gcc/cp/ChangeLog: PR c++/95181 * class.c (add_method): Let special member function templates coexist if they are not equivalently constrained, or in a class template. gcc/testsuite/ChangeLog: PR c++/95181 * g++.dg/concepts/pr95181.C: New test. * g++.dg/concepts/pr95181-2.C: New test. Co-authored-by: Jason Merrill <jason@redhat.com>
The releases/gcc-10 branch has been updated by Jason Merrill <jason@gcc.gnu.org>: https://gcc.gnu.org/g:9e81c820a3e48ead478dabbd6988482747f7a521 commit r10-8212-g9e81c820a3e48ead478dabbd6988482747f7a521 Author: Patrick Palka <ppalka@redhat.com> Date: Fri May 22 10:28:19 2020 -0400 c++: P0848R3 and member function templates [PR95181] When comparing two special member function templates to see if one hides the other (as per P0848R3), we need to check satisfaction which we can't do on templates. So this patch makes add_method skip the eligibility test on member function templates and just lets them coexist. gcc/cp/ChangeLog: PR c++/95181 * class.c (add_method): Let special member function templates coexist if they are not equivalently constrained, or in a class template. gcc/testsuite/ChangeLog: PR c++/95181 * g++.dg/concepts/pr95181.C: New test. * g++.dg/concepts/pr95181-2.C: New test. Co-authored-by: Jason Merrill <jason@redhat.com> (cherry picked from commit 6b449b74c590f5a6f66c73aed894e5b5b36aa59d)
Fixed for 10.2/11.