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

            Bug ID: 85292
           Summary: multiple definition of default argument emitted
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: no...@turm-lahnstein.de
  Target Milestone: ---

Please consider the following code:

#include <functional>


namespace timeit{
    typedef std::function <void (void)> Fun;

    //returns time needed for execution in seconds, calls setup once
    template<typename Fun1>
    void timeit(const Fun1 &f, const Fun &setup=[]{})
    {  
       setup();
       f();
    }
}

int main(){
   timeit::timeit([](){return 0.0;});
   timeit::timeit([](){ return; });
}

When trying to compile, I get the following error message:

/tmp/cc4aRGV3.s: Assembler messages:

/tmp/cc4aRGV3.s:36: Error: symbol
`_ZNSt14_Function_base13_Base_managerIN6timeitUlvE_EE10_M_managerERSt9_Any_dataRKS4_St18_Manager_operation'
is already defined

/tmp/cc4aRGV3.s:58: Error: symbol
`_ZNSt17_Function_handlerIFvvEN6timeitUlvE_EE9_M_invokeERKSt9_Any_data' is
already defined

See it live at http://coliru.stacked-crooked.com/a/da080519413414da

I don't see, why this code should not compile (and if it is ill-formed then the
compiler and not the assembler should report the error).

Reply via email to