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

DB <db0451 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=93154

--- Comment #5 from DB <db0451 at gmail dot com> ---
This might have the same root cause as 93154, as in both cases, it looks like
the compiler is mixing up the template arguments of the outer function and the
inner lambda.

Here, we are told that "‘OtherSub’ is not a base of ‘WeirdSub’", despite that
we never asked the compiler to make that constraint.

and from 93154:

```
#include <concepts>

void f1(int) {}

template <typename F>
auto
make_lambda(F f)
{
        return [f] <typename Arg>
                   requires std::invocable<F, Arg>
               (Arg a)
        {
                f(a);
        };
}

auto
main() -> int
{
        auto const lambda = make_lambda(&f1);
        lambda(42);

        return 0;
}
```

...which somehow ends up with the compiler trying to check whether `int` is
`std::invocable`!

>>>
test5.cpp: In function ‘int main()’:
test5.cpp:19:11: error: no match for call to ‘(const make_lambda(F) [with F =
void (*)(int)]::<lambda(Arg)>) (int)’
   19 |  lambda(42);
      |           ^
test5.cpp:9:9: note: candidate: ‘make_lambda(F) [with F = void
(*)(int)]::<lambda(Arg)> [with Arg = int]’
    9 |  return [f] <typename Arg> requires std::invocable<F, Arg> (Arg a)
      |         ^
test5.cpp:9:9: note: constraints not satisfied
In file included from test5.cpp:1:
/usr/include/c++/10/concepts: In instantiation of ‘make_lambda(F) [with F =
void (*)(int)]::<lambda(Arg)> [with Arg = int]’:
test5.cpp:19:11:   required from here
/usr/include/c++/10/concepts:344:13:   required for the satisfaction of
‘invocable<int, Arg>’
/usr/include/c++/10/concepts:344:25: note: the expression ‘is_invocable_v<_Fn,
_Args ...>’ evaluated to ‘false’
  344 |     concept invocable = is_invocable_v<_Fn, _Args...>;
>>>

Reply via email to