https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86361
Bug ID: 86361 Summary: Compilation failed while other compiler(clang) able to compile code in question Product: gcc Version: 4.8.5 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: husen.hunedbhai.jiruwala at citi dot com Target Milestone: --- Compilation for below code fails for all version of gcc except 8.1 #include<iostream> using namespace std; int main() { const int k = 10; // Capture k by value auto myl = [k] (int k) { cout << " ++k=" << ++k ; }; myl(k+10); } Below stackoverflow discussion suggests that it should not compile with gcc 8.1 as well. https://stackoverflow.com/questions/51060581/why-this-code-fails-to-compile-with-gcc-4-8-5-while-it-compiles-fine-with-clang/51101002#51101002 So its either a bug in gcc 8.1 or all other version. please kindly check.