https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122646
Nathaniel Shead <nshead at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2025-11-13
CC| |nshead at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Confirmed. Looks like maybe another strange interaction with friend functions.
This is what I've managed to reduce it to:
// a.cpp
export module M;
template <typename T>
struct zip_view_iterator {
void operator-(int) {}
friend void operator-(zip_view_iterator, zip_view_iterator)
requires requires(T x) { x.begin() - x.begin(); }
{}
};
struct ref_view {
ref_view begin();
};
export template <typename X> void foo() {
zip_view_iterator<ref_view>{} - X();
}
// b.cpp
import M;
template void foo<int>();
$ g++ -fmodules -S -std=c++23 a.cpp b.cpp
In module M, imported at b.cpp:1:
a.cpp: In instantiation of ‘void operator-@M(zip_view_iterator@M<ref_view@M>,
zip_view_iterator@M<ref_view@M>) requires requires(T x) {x.begin() -
x.begin();}’:
required from ‘void operator-@M(zip_view_iterator@M<ref_view@M>,
zip_view_iterator@M<ref_view@M>) requires requires(T x) {x.begin() -
x.begin();}’
a.cpp:7:40:
7 | requires requires(T x) { x.begin() - x.begin(); }
| ~~~~~~~~~~^~~~~~~~~~~
required from ‘void foo@M() [with X = int]’
a.cpp:16:33:
16 | zip_view_iterator<ref_view>{} - X();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
required from here
b.cpp:2:24:
2 | template void foo<int>();
| ^
required by the constraints of ‘template<class T> void
operator-@M(zip_view_iterator@M<T>, zip_view_iterator@M<T>) requires requires(T
x) {x.begin() - x.begin();}’
a.cpp:6:15:
6 | friend void operator-(zip_view_iterator, zip_view_iterator)
| ^~~~~~~~
in requirements with ‘T x’ [with T = ref_view]
a.cpp:7:14:
7 | requires requires(T x) { x.begin() - x.begin(); }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cpp:7:14: error: satisfaction of atomic constraint ‘requires(T x) {x.begin()
- x.begin();} [with T = T]’ depends on itself