This patch fixes GCC Bug 108760: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108760 Before this patch, using std::ranges::iota required including when it should have been sufficient to only include . When the patch is applied, the following code will compile: https://godbolt.org/z/33EPeqd1b I added a test case for this change as well. I built my local version of gcc using the following configuration: $ ../gcc/configure --disable-bootstrap --prefix="$(pwd)/_pfx/" --enable-languages=c,c++,lto and I tested my changes by running: $ make check-c++ -jN -k I ran this on the following OS: Virtualization: wsl Operating System: Ubuntu 20.04.6 LTS Kernel: Linux 5.15.146.1-microsoft-standard-WSL2 Architecture: x86-64