summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/torture/pr49770.C
blob: 8180648cbe6ecf45c402133ea45d7ba484ebd447 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* { dg-do run { target c++11 } } */
/* { dg-options "-fno-tree-forwprop" } */

typedef __SIZE_TYPE__ size_t;

template < typename > struct remove_reference;
template < typename _Tp > struct remove_reference <_Tp & >
{
  typedef _Tp type;
};
template < typename _Tp > typename remove_reference < _Tp >::type &&
move (_Tp && __t)
{
  return static_cast < typename remove_reference < _Tp >::type && >(__t);
}

template < typename _Tp > void
stdswap (_Tp & __a, _Tp & __b)
{
  _Tp __tmp (__a);
  __a = (__b);
  __b = (__tmp);
}

struct _Deque_iterator
{
  int *_M_cur;
  int *_M_first;
  int *_M_last;
  int **_M_node;
};

static inline int operatorMIN (_Deque_iterator & __x, _Deque_iterator & __y)
{
  return sizeof (int) * (__x._M_node - __y._M_node - 1)
    + (__x._M_cur - __x._M_first) + (__y._M_last - __y._M_cur);
}

struct deque
{
  deque & operator = (deque && __x)
  {
    stdswap (_M_finish, __x._M_finish);
    return *this;
  }
  size_t size ()
  {
    return operatorMIN (_M_finish, _M_start);
  }

deque ():
  _M_map (), _M_map_size (), _M_start (), _M_finish ()
  {
    _M_start._M_last = _M_start._M_first + sizeof (int);
  }

  int **_M_map;
  size_t _M_map_size;
  _Deque_iterator _M_start;
  _Deque_iterator _M_finish;
};

struct queue
{
  deque c;
  size_t size ()
  {
    return c.size ();
  }
};

void
test01 ()
{
  queue a, b;
  ++a.c._M_finish._M_cur;
  b = move (a);
  if (!b.size ())
    __builtin_abort ();
}

main ()
{
  test01 ();
}