Bug 94241 - ranges::find_if doesn't like data structures defined in a function
Summary: ranges::find_if doesn't like data structures defined in a function
Status: RESOLVED DUPLICATE of bug 92894
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2020-03-20 17:43 UTC by Christopher Di Bella
Modified: 2020-03-20 21:07 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Temp for minimal repro (204.68 KB, application/x-gzip)
2020-03-20 17:45 UTC, Christopher Di Bella
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Di Bella 2020-03-20 17:43:17 UTC
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
Comment 1 Christopher Di Bella 2020-03-20 17:45:43 UTC
Created attachment 48074 [details]
Temp for minimal repro
Comment 2 Andrew Pinski 2020-03-20 17:52:02 UTC
#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; });
}
Comment 3 Andrew Pinski 2020-03-20 17:52:59 UTC
This looks like a front-end issue rather than a library issue.
Comment 4 Jonathan Wakely 2020-03-20 21:07:31 UTC
(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 ***