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

            Bug ID: 65870
           Summary: Explicit function instantiation with default valued
                    lambda causes duplicate symbol
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: w.shane.grant at gmail dot com

When explicitly instantiating functions with default lambda parameters, g++
generates multiple versions of the lambda with the same symbol names.

I've created a minimal example:

struct Any
{
  template <class T>
  Any( T const & ){}
};

template <class T>
void func( T t, Any a = [](){} ){}

template void func<int>( int, Any );
template void func<double>( double, Any );

int main()
{
  func( 3 );
  func( 3.0 );

  return 0;
}

Compiled with g++ -std=c++11 (4.7.4, 4.8.3, and 4.9.1) , this causes the error:

/tmp/ccND7XlM.s:104: Error: symbol `_ZN3AnyC2IUlvE_EERKT_' is already defined

If this is indeed incorrect behavior (I don't know enough about the spec to
confirm this), I believe the problem is that the name mangling for the lambda
is not taking the parent template into account.

Reply via email to