Created attachment 31954 [details] sample file causing the bug I have a template function that takes an std::function argument. This argument has a default value, an in-place declared lambda function. As soon as I use that template function more than once with different types within a compilation unit I receive error messages from the assembler about symbols that are defined already. I've distilled it down to a code snippet I'm going to attach. In the original code the lambda function was actually using the template parameter T and could therefore not be converted to standalone function. This fails with 4.8 and 4.8.2, but I remember it failing back as early as 4.6.3. It works nicely with clang++ 3.3 and 3.4. With »works nicely« I mean that it compiles cleanly, links, and the resulting code does what I want it to (in my original source; this sample code obviously doesn't do anything at all). The command line used: g++ -std=c++11 -o cpp1 cpp1.cpp
Created attachment 31955 [details] compiler output with g++ 4.8.2
The problem is unrelated to std::function: struct A { template<typename T> A(T) { } }; template<typename T> void stuff(A = []{ }) { } int main() { stuff<int>(); stuff<unsigned int>(); }
This bug is still present in g++ 6.4.0.
Author: paolo Date: Wed Sep 13 11:57:56 2017 New Revision: 252079 URL: https://gcc.gnu.org/viewcvs?rev=252079&root=gcc&view=rev Log: 2017-09-13 Paolo Carlini <paolo.carlini@oracle.com> PR c++/59949 * g++.dg/cpp0x/lambda/lambda-defarg7.C: New. Added: trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg7.C Modified: trunk/gcc/testsuite/ChangeLog
Fixed in trunk.
*** Bug 65870 has been marked as a duplicate of this bug. ***
*** Bug 78919 has been marked as a duplicate of this bug. ***