ranges::find_if chucks a wobbly when a struct is defined inside a function. Seems to cooperate if the struct is in global scope. # Diagnostic ``` In file included from /usr/local/include/c++/10.0.1/bits/stl_iterator_base_types.h:71, from /usr/local/include/c++/10.0.1/bits/stl_algobase.h:65, from /usr/local/include/c++/10.0.1/algorithm:61, from ice.cpp:1: /usr/local/include/c++/10.0.1/bits/iterator_concepts.h:669:40: error: 'std::indirect_result_t<_Proj&, _Iter> std::projected<_Iter, _Proj>::operator*() const [with _Iter = main()::s*; _Proj = std::identity; std::indirect_result_t<_Proj&, _Iter> = main()::s&]', declared using local type 'main()::s', is used but never defined [-fpermissive] 669 | indirect_result_t<_Proj&, _Iter> operator*() const; // not defined | ``` # System info OS: Ubuntu 18.04 (WSL) Version: gcc (GCC) 10.0.1 20200320 (experimental) Git hash: Configured with: ../gcc/configure --disable-nls --disable-multilib --enable-languages=c,c++ --disable-werror : (reconfigured) ../gcc/configure --disable-nls --disable-multilib --enable-languages=c,c++ --disable-werror : (reconfigured) ../gcc/configure --disable-nls --disable-multilib --disable-werror CC=/usr/local/bin/gcc CFLAGS='-O3 -g0 -w' LDFLAGS=-fuse-ld=gold CXX=/usr/local/bin/g++ CXXFLAGS='-O3 -g0 -w' --enable-languages=c,c++,lto --no-create --no-recursion
Created attachment 48074 [details] Temp for minimal repro
#include <algorithm> int main() { struct s { int m; }; s r[] = { s{0}, s{1}, s{2}, s{3} }; std::ranges::find_if(r, [](auto const) { return true; }); }
This looks like a front-end issue rather than a library issue.
(In reply to Andrew Pinski from comment #3) > This looks like a front-end issue rather than a library issue. Yes. I hit this when I started implementing the ranges:: algos and trying to test them, and reported it as PR 92894. *** This bug has been marked as a duplicate of bug 92894 ***