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

            Bug ID: 119981
           Summary: Regression with lambda as auto template param
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lukester_null at yahoo dot co.uk
  Target Milestone: ---

Hi

This:

template<typename A, typename B>
inline constexpr bool is_same_v = true;

template<typename... Ts>
struct mp_list
{
};

template<class L, template<class...> class P>
struct mp_copy_if
{
        using type = L;
};

template<auto Fn>
struct make_bool_metafunction
{
        template<typename... Ts>
        struct fn
        {
                static constexpr bool value = true;
        };
};

template<typename TypeList, auto Predicate>
using copy_if = typename mp_copy_if<TypeList,
make_bool_metafunction<Predicate>::template fn>::type;

template<typename...>
bool test3()
{
        using l1 = copy_if<mp_list<>, []<typename T>() { return true; }>;

        return is_same_v<l1, l1>;
}

int main()
{
        test3();
}

fails to compile with:

main.cpp: In instantiation of ‘bool test3() [with <template-parameter-1-1> =
{}]’:
main.cpp:40:7:   required from here
   40 |         test3();
      |         ~~~~~^~
main.cpp:35:16: error: no class template named ‘fn’ in ‘struct
make_bool_metafunction<<lambda> >’
   35 |         return is_same_v<l1, l1>;
      |                ^~~

See https://godbolt.org/z/1dM8fjvoG specifically the 15.1 compiler version.
Note the other test functions there that compile OK.

I thought this was a 15 regression, but it turns out the 14.2 branch is now
exhibiting the same behaviour. A bisect shows this broke with this commit:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d025b6880cde2cb2063b4d34546cdd70e5526e74

Looks like the equivalent gcc 15 commit is
f04dc89a991ddc6c08ac92c8ad29c6915c4ecafa.

Thanks!

Reply via email to