2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / torture / 20090329-1.C
blob6839931a2478d85e7ead489e26c2b8be55fb4871
1 /* { dg-do compile } */
2 /* { dg-additional-options "-Wno-return-type" } */
4 struct input_iterator_tag { };
5 template<typename _Category, typename _Tp, typename _Distance = long, typename _Pointer = _Tp*, typename _Reference = _Tp&>
6 struct iterator {
7     typedef _Category iterator_category;
8 };
9 template<typename _Iterator> struct iterator_traits {
10     typedef typename _Iterator::iterator_category iterator_category;
12 template<typename, typename> struct __lc_rai {
13     template<typename _II1, typename _II2>
14         static _II1 __newlast1(_II1, _II1 __last1, _II2, _II2) {
15             return __last1;
16         }
17     template<typename _II> 
18         static bool __cnd2(_II __first, _II __last) {
19             return __first != __last;
20         }
22 template<typename _II1, typename _II2, typename _Compare>
23 bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2,
24                              _II2 __last2, _Compare __comp) {
25     typedef typename iterator_traits<_II1>::iterator_category _Category1;
26     typedef typename iterator_traits<_II2>::iterator_category _Category2;
27     typedef __lc_rai<_Category1, _Category2> __rai_type;
28     __last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2);
29     for (;
30          __first1 != __last1 && __rai_type::__cnd2(__first2, __last2);
31          ++__first1, ++__first2) {
32         if (__comp(*__first1, *__first2)) return true;
33     }
35 void __assert_fail () throw () __attribute__ ((__noreturn__));
36 template<typename T> struct BoundsContainer { };
37 template<class T> class input_iterator_wrapper : public iterator<input_iterator_tag, T, long, T*, T&> {
38 public:
39     typedef BoundsContainer<T> ContainerType;
40     T* ptr;
41     ContainerType* SharedInfo;
42     input_iterator_wrapper(const input_iterator_wrapper& in) : ptr(in.ptr), SharedInfo(in.SharedInfo) { }
43     bool operator==(const input_iterator_wrapper& in) const {
44         (static_cast<void> ((SharedInfo != __null
45                              && SharedInfo == in.SharedInfo)
46                             ? 0 : (__assert_fail (), 0)));
47     }
48     bool operator!=(const input_iterator_wrapper& in) const {
49         return !(*this == in);
50     }
51     T& operator*() const { }
52     input_iterator_wrapper& operator++() { }
54 struct X { };
55 bool predicate(const X&, const X&) {
56     return true;
58 bool test2(input_iterator_wrapper<X>& x) {
59     return lexicographical_compare(x, x, x, x, predicate);