https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78919
Bug ID: 78919 Summary: Lambdas, default parameters and std::functional cause assembly error Product: gcc Version: 5.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kirit.saelensminde at gmail dot com Target Milestone: --- There seems to be some odd interaction with default parameters, lambdas and std::function. // Compile with: // g++ --std=c++11 -Wall -Wextra bug.cpp // g++ --std=c++14 -Wall -Wextra bug.cpp #include <functional> #include <iostream> template<typename F> void foo(F fn, std::function<void(void)> = [](){}) { fn(); } int main() { foo([](){ std::cout << "First" << std::endl;}); foo([](){ std::cout << "Second" << std::endl;}); } If the second call to `foo` is removed then it works fine. Otherwise there are assembler errors like the below: /tmp/ccwG9slS.s: Assembler messages: /tmp/ccwG9slS.s:252: Error: symbol `_ZNKUlvE_clEv' is already defined /tmp/ccwG9slS.s:537: Error: symbol `_ZSt4moveIRUlvE_EONSt16remove_referenceIT_E4typeEOS3_' is already defined /tmp/ccwG9slS.s:555: Error: symbol `_ZNSt8functionIFvvEEC2IUlvE_vvEET_' is already defined /tmp/ccwG9slS.s:813: Error: symbol `_ZNSt14_Function_base13_Base_managerIUlvE_E21_M_not_empty_functionIS1_EEbRKT_' is already defined /tmp/ccwG9slS.s:830: Error: symbol `_ZNSt14_Function_base13_Base_managerIUlvE_E15_M_init_functorERSt9_Any_dataOS1_' is already defined /tmp/ccwG9slS.s:871: Error: symbol `_ZNSt17_Function_handlerIFvvEUlvE_E9_M_invokeERKSt9_Any_data' is already defined /tmp/ccwG9slS.s:894: Error: symbol `_ZNSt14_Function_base13_Base_managerIUlvE_E10_M_managerERSt9_Any_dataRKS3_St18_Manager_operation' is already defined /tmp/ccwG9slS.s:1122: Error: symbol `_ZNSt14_Function_base13_Base_managerIUlvE_E15_M_init_functorERSt9_Any_dataOS1_St17integral_constantIbLb1EE' is already defined /tmp/ccwG9slS.s:1151: Error: symbol `_ZNSt14_Function_base13_Base_managerIUlvE_E14_M_get_pointerERKSt9_Any_data' is already defined /tmp/ccwG9slS.s:1176: Error: symbol `_ZNSt9_Any_data9_M_accessIPUlvE_EERT_v' is already defined /tmp/ccwG9slS.s:1196: Error: symbol `_ZNSt14_Function_base13_Base_managerIUlvE_E8_M_cloneERSt9_Any_dataRKS3_St17integral_constantIbLb1EE' is already defined /tmp/ccwG9slS.s:1225: Error: symbol `_ZNSt14_Function_base13_Base_managerIUlvE_E10_M_destroyERSt9_Any_dataSt17integral_constantIbLb1EE' is already defined /tmp/ccwG9slS.s:1306: Error: symbol `_ZNKSt9_Any_data9_M_accessIUlvE_EERKT_v' is already defined /tmp/ccwG9slS.s:1326: Error: symbol `_ZSt11__addressofIKUlvE_EPT_RS2_' is already defined /tmp/ccwG9slS.s:1344: Error: symbol `_ZNSt9_Any_data9_M_accessIUlvE_EERT_v' is already defined As well as 5.4.1 this bug happens in 6.2.0 and 6.2.1. We've tried this on Ubuntu versions and Arch linux versions of the compilers. This looks somewhat similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65919 but the errors appear quite different.