Bug 95181 - [10/11 Regression] ICE in push_access_scope, at cp/pt.c:241 since r10-3735-gcb57504a55015891
Summary: [10/11 Regression] ICE in push_access_scope, at cp/pt.c:241 since r10-3735-gc...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 10.1.0
: P2 normal
Target Milestone: 10.2
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2020-05-17 22:25 UTC by ahmet özhan
Modified: 2020-06-01 19:51 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-05-18 00:00:00


Attachments
gcc 10 don't compile but clang compile (427 bytes, text/plain)
2020-05-17 22:25 UTC, ahmet özhan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ahmet özhan 2020-05-17 22:25:28 UTC
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
Comment 1 ahmet özhan 2020-05-17 22:29:52 UTC
gcc 9.3 compile
Comment 2 ahmet özhan 2020-05-17 22:31:33 UTC
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;
>}
Comment 3 ahmet özhan 2020-05-17 22:32:41 UTC
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;
>}
Comment 4 Martin Liška 2020-05-18 06:10:24 UTC
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.
Comment 5 Patrick Palka 2020-05-18 12:43:16 UTC
Another testcase:

template <typename> class f {
  template <typename> f();
  template <typename> requires false f();
};
Comment 6 Patrick Palka 2020-05-18 20:40:36 UTC
I will look into this.
Comment 7 Patrick Palka 2020-05-28 15:51:56 UTC
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.
Comment 8 GCC Commits 2020-05-29 22:19:12 UTC
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>
Comment 9 GCC Commits 2020-05-30 02:11:33 UTC
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)
Comment 10 Jason Merrill 2020-06-01 19:51:22 UTC
Fixed for 10.2/11.