[Bug c++/83115] New: Capturing the local variable/function parameter by value generates an compilation error

alexandr.kolesov at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 22 19:54:00 GMT 2017


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

            Bug ID: 83115
           Summary: Capturing the local variable/function parameter by
                    value generates an compilation error
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alexandr.kolesov at gmail dot com
  Target Milestone: ---

// This simple code cannot be compiled in some cases:

#include <iostream>
#include <chrono>

void doSomething(const double value)
{
   [ now = std::chrono::system_clock::now(), value]{}(); // Error
// [ now = std::chrono::system_clock::now(), value = value]{}(); // OK
// [ value, now = std::chrono::system_clock::now()]{}(); // OK
}

int main()
{
   doSomething(42.0);
   return 0;
}


More information about the Gcc-bugs mailing list