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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jason Liam from comment #3)
> [expr.prim.lambda.closure] states:
> 
> > The type of a lambda-expression (which is also the type of the closure 
> > object) is a unique, unnamed non-union class type, called the closure type, 
> > ...
> 
> -------------------------
> 
> 
> In cppinsight clang create new class-type each time. Demo
> https://cppinsights.io/s/abca4605

I think you are reading the output incorrectly.
It creates 2 different closures but of the same type (__lambda_4_17).
See https://godbolt.org/z/K17obKdr1 also.

That happens also for GCC:
  (void) std::basic_ostream<char>::operator<< ((struct basic_ostream *)
std::basic_ostream<char>::operator<< (&cout, foo (<lambda()>::operator()
(&TARGET_EXPR <D.59246, {}>))), foo (<lambda()>::operator() (&TARGET_EXPR
<D.59260, {}>))) >>>>>;

TARGET_EXPR <D.59246, {}> and TARGET_EXPR <D.59260, {}> are the two temp
variables for the closures.

Reply via email to