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

2017-11-22 Thread alexandr.kolesov at gmail dot com
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 
#include 

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;
}

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

2017-11-22 Thread alexandr.kolesov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83115

--- Comment #1 from Alexander Kolesov  ---
The error we can see:

prog.cc: In function 'void doSomething(double)':
prog.cc:6:44: error: 'value' was not declared in this scope
  [ now = std::chrono::system_clock::now(), value]{}();
^
prog.cc:6:44: error: declaration of 'value' shadows a
parameter
prog.cc:4:31: warning: unused parameter 'value' [-Wunused-parameter]
 void doSomething(const double value)
  ~^