https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95197
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Reduced testcase: // { dg-do link } typedef __PTRDIFF_TYPE__ ptrdiff_t; template <typename T> class I { public: typedef ptrdiff_t difference_type; I (); ~I (); I (T *); I (const I &); T &operator * (); T *operator -> (); T &operator [] (const difference_type &) const; I &operator = (const I &); I &operator ++ (); I operator ++ (int); I &operator -- (); I operator -- (int); I &operator += (const difference_type &); I &operator -= (const difference_type &); I operator + (const difference_type &) const; I operator - (const difference_type &) const; template <typename S> friend bool operator == (I<S> &, I<S> &); template <typename S> friend bool operator == (const I<S> &, const I<S> &); template <typename S> friend bool operator < (I<S> &, I<S> &); template <typename S> friend bool operator < (const I<S> &, const I<S> &); template <typename S> friend bool operator <= (I<S> &, I<S> &); template <typename S> friend bool operator <= (const I<S> &, const I<S> &); template <typename S> friend bool operator > (I<S> &, I<S> &); template <typename S> friend bool operator > (const I<S> &, const I<S> &); template <typename S> friend bool operator >= (I<S> &, I<S> &); template <typename S> friend bool operator >= (const I<S> &, const I<S> &); template <typename S> friend typename I<S>::difference_type operator - (I<S> &, I<S> &); template <typename S> friend typename I<S>::difference_type operator - (const I<S> &, const I<S> &); template <typename S> friend I<S> operator + (typename I<S>::difference_type , const I<S> &); private: T *p; }; template <typename T> I<T>::I () : p (0) {} template <typename T> I<T>::~I () {} template <typename T> I<T>::I (T *x) : p (x) {} template <typename T> I<T>::I (const I &x) : p (x.p) {} template <typename T> T &I<T>::operator * () { return *p; } template <typename T> T *I<T>::operator -> () { return p; } template <typename T> T &I<T>::operator [] (const difference_type &x) const { return p[x]; } template <typename T> I<T> &I<T>::operator = (const I &x) { p = x.p; return *this; } template <typename T> I<T> &I<T>::operator ++ () { ++p; return *this; } template <typename T> I<T> I<T>::operator ++ (int) { return I (p++); } template <typename T> I<T> &I<T>::operator -- () { --p; return *this; } template <typename T> I<T> I<T>::operator -- (int) { return I (p--); } template <typename T> I<T> &I<T>::operator += (const difference_type &x) { p += x; return *this; } template <typename T> I<T> &I<T>::operator -= (const difference_type &x) { p -= x; return *this; } template <typename T> I<T> I<T>::operator + (const difference_type &x) const { return I (p + x); } template <typename T> I<T> I<T>::operator - (const difference_type &x) const { return I (p - x); } template <typename T> bool operator == (I<T> &x, I<T> &y) { return x.p == y.p; } template <typename T> bool operator == (const I<T> &x, const I<T> &y) { return x.p == y.p; } template <typename T> bool operator != (I<T> &x, I<T> &y) { return !(x == y); } template <typename T> bool operator != (const I<T> &x, const I<T> &y) { return !(x == y); } template <typename T> bool operator < (I<T> &x, I<T> &y) { return x.p < y.p; } template <typename T> bool operator < (const I<T> &x, const I<T> &y) { return x.p < y.p; } template <typename T> bool operator <= (I<T> &x, I<T> &y) { return x.p <= y.p; } template <typename T> bool operator <= (const I<T> &x, const I<T> &y) { return x.p <= y.p; } template <typename T> bool operator > (I<T> &x, I<T> &y) { return x.p > y.p; } template <typename T> bool operator > (const I<T> &x, const I<T> &y) { return x.p > y.p; } template <typename T> bool operator >= (I<T> &x, I<T> &y) { return x.p >= y.p; } template <typename T> bool operator >= (const I<T> &x, const I<T> &y) { return x.p >= y.p; } template <typename T> typename I<T>::difference_type operator - (I<T> &x, I<T> &y) { return x.p - y.p; } template <typename T> typename I<T>::difference_type operator - (const I<T> &x, const I<T> &y) { return x.p - y.p; } template <typename T> I<T> operator + (typename I<T>::difference_type x, const I<T> &y) { return I<T> (x + y.p); } void bar (I<int> &a) { } void foo (const I<int> &a, const I<int> &b) { I<int> i; #pragma omp distribute parallel for for (i = a; i < b; i++) bar (i); } int main () { int a[64]; foo (&a[0], &a[63]); }