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

            Bug ID: 108242
           Summary: '__FUNCTION__' was not declared when used inside a
                    lambda declared inside a template function
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: n.eugene536 at gmail dot com
  Target Milestone: ---

Target: x86_64-linux-gnu
Broken since gcc 12.1; works fine with gcc <= 11.3

g++ a.cpp -std=c++14

template<class F>
void my_fun()
{
    auto fun = [&](auto res) {
        static constexpr char const* fun_name = __FUNCTION__;
        struct
        {
            constexpr const char* operator()() const { return fun_name; };
        } t;
        t();
    };

    fun(12);
}


int main() {
    my_fun<int>();
}


output: Compilation error
source>:8:63: error: '__FUNCTION__' was not declared in this scope
    8 |             constexpr const char* operator()() const { return fun_name;
};


expected: successful compilation

Works perfectly fine with clang

Reply via email to