public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114495] New: Capture error in lambda fold
@ 2024-03-27  6:27 andipeer at gmx dot net
  2024-03-27  7:49 ` [Bug c++/114495] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: andipeer at gmx dot net @ 2024-03-27  6:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114495
           Summary: Capture error in lambda fold
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andipeer at gmx dot net
  Target Milestone: ---

The following code

#include <utility>

template <typename... Args>
void func(Args... args)
{
    auto f = [&]<std::size_t... Indices>(std::index_sequence<Indices...>,
Args... args) {
        auto f2 = [&](auto, auto) { };
        (f2(Indices, args), ...);
    };
    f(std::make_index_sequence<sizeof...(args)>(),
std::forward<Args>(args)...);
}

int main()
{
  func(3);
  return 1;
}

is accepted by Clang and MSVC, but fails on GCC with 
  error: 'args#0' is not captured
   (f2(Indices, args), ...);

It however compiles when changing the signature of the lambda `f` to use `auto`
instead of `Args` for the second parameter:

auto f = [&]<std::size_t... Indices>(std::index_sequence<Indices...>, auto...
args)


Online demo: https://gcc.godbolt.org/z/TjexTjhnc

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/114495] Capture error in lambda fold
  2024-03-27  6:27 [Bug c++/114495] New: Capture error in lambda fold andipeer at gmx dot net
@ 2024-03-27  7:49 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-27  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup.

*** This bug has been marked as a duplicate of bug 114167 ***

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-27  7:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-27  6:27 [Bug c++/114495] New: Capture error in lambda fold andipeer at gmx dot net
2024-03-27  7:49 ` [Bug c++/114495] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).