| 1 | // { dg-options "-pedantic" } |
| 2 | // { dg-do compile } |
| 3 | |
| 4 | #include <algorithm> |
| 5 | |
| 6 | /* This type is reduced from QTypedArrayData::iterator which has an implicit |
| 7 | * conversion to its pointer type and a difference type of int. |
| 8 | * The expression Iter() + ptrdiff_t(0) is ambiguous with -pedantic because it |
| 9 | * could either convert the RHS to int and use Iter::operator+(int) |
| 10 | * or it could convert the LHS to pointer and use built-in pointer arithmetic. |
| 11 | */ |
| 12 | struct Iter |
| 13 | { |
| 14 | struct value_type { bool operator<(value_type) const; }; |
| 15 | typedef value_type* pointer; |
| 16 | typedef value_type& reference; |
| 17 | typedef std::random_access_iterator_tag iterator_category; |
| 18 | typedef int difference_type; |
| 19 | |
| 20 | reference operator*() const; |
| 21 | pointer operator->() const; |
| 22 | |
| 23 | reference operator[](difference_type) const; |
| 24 | |
| 25 | Iter& operator++(); |
| 26 | Iter& operator--(); |
| 27 | Iter operator++(int); |
| 28 | Iter operator--(int); |
| 29 | |
| 30 | Iter& operator+=(difference_type); |
| 31 | Iter& operator-=(difference_type); |
| 32 | |
| 33 | Iter operator+(difference_type) const; |
| 34 | Iter operator-(difference_type) const; |
| 35 | |
| 36 | difference_type operator-(Iter) const; |
| 37 | |
| 38 | operator pointer() const; // XXX this causes the ambiguity |
| 39 | |
| 40 | bool operator==(Iter) const; |
| 41 | bool operator!=(Iter) const; |
| 42 | |
| 43 | bool operator<(Iter) const; |
| 44 | }; |
| 45 | |
| 46 | Iter operator+(Iter::difference_type, Iter); |
| 47 | |
| 48 | int main() |
| 49 | { |
| 50 | std::stable_sort(Iter(), Iter()); |
| 51 | } |