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

            Bug ID: 106372
           Summary: error: redefinition of ‘const char *mangled function
                    name*[]’
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: striker159 at web dot de
  Target Milestone: ---

The following minimal code compiles with g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) ,
but does not compile with g++-11 (Ubuntu 11.1.0-1ubuntu1~20.04). Target:
x86_64-linux-gnu

---------------------------------

Error message:
bug1.cpp:26:2: error: redefinition of ‘const char
_ZTSZN1AIjEC4ESt8functionIFmmEEEd_UlT_E_ []’
   26 | };
      |  ^
bug1.cpp:26:2: note: ‘const char _ZTSZN1AIjEC4ESt8functionIFmmEEEd_UlT_E_ [37]’
previously defined here

---------------------------------


//g++-11 -std=c++17 -Wall -Wextra -O3 bug1.cpp -c -o bug1_g++11.o

#include <memory>
#include <cstdint>
#include <functional>

template<class T>
struct A{
    using Callback = std::function<std::size_t(std::size_t)>; 

    A(Callback pol = [](auto){return 42;}){
        pol(1);
    }
};

struct B{
    B() = default;

    B(int){}

    A<std::uint32_t> member;
};

struct C{
    void foo() {
        auto ptr = std::make_unique<B>();
    } 
};

Reply via email to