https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77792

            Bug ID: 77792
           Summary: Generic lamdba scope issue when working with
                    list::remove_if
           Product: gcc
           Version: 6.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michele.caini at gmail dot com
  Target Milestone: ---

Consider the following code:

    #include<algorithm>
    #include<list>

    template<typename U>
    struct S {
        using FT = void(*)(); 
        struct T { FT func; };

        template<typename> 
        static void f() { } 

        std::list<T> l{ { &f<int> }, { &f<char> } };

        void run() {
            l.remove_if([](const T &t) { return t.func == &f<int>; }); // (1)
            l.remove_if([](const auto &t) { return t.func == &f<int>; }); //
(2)
        }
    };

    int main() { 
        S<void> s;
        s.run();
    }

(1) compiles fine, (2) doesn't compile with the error:

> error: 'f' was not declared in this scope

Note also that it compiles if modified as it follows:

    l.remove_if([](const auto &t) { return t.func == &S<U>::f<int>; }); // (2)

Reply via email to