1 // PR c++/69315
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-O2" }
4 
5 // Template instantiation and evaluation for folding within
6 // finish_function may call finish_function recursively.
7 // Make sure we don't reject or delay that sort of recursion.
8 
9 template <bool> struct Iter;
10 
11 struct Arg {
12   Iter<true> begin();
13   Iter<true> end();
14 };
15 
16 template <bool> struct Iter {
17   int operator*();
18   Iter operator++();
19   template <bool C1, bool C2> friend constexpr bool operator==(Iter<C1>, Iter<C2>);
20   template <bool C1, bool C2> friend constexpr bool operator!=(Iter<C1>, Iter<C2>);
21 };
22 
func(Arg a)23 void func(Arg a) {
24   for (auto ch : a) {
25     a.begin() == a.end();
26   }
27 }
28 
29 template <bool C1, bool C2> constexpr bool operator==(Iter<C1>, Iter<C2>) {
30   return true;
31 }
32 
33 template <bool C1, bool C2> constexpr bool operator!=(Iter<C1> a, Iter<C2> b) {
34   return a == b;
35 }
36