[Bug libstdc++/99907] New: (On MS Windows) Multiple definition errors with <coroutine> included in two translation units

rcopley at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Apr 4 11:38:25 GMT 2021


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

            Bug ID: 99907
           Summary: (On MS Windows) Multiple definition errors with
                    <coroutine> included in two translation units
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rcopley at gmail dot com
  Target Milestone: ---

Created attachment 50506
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50506&action=edit
testcase

The attached testcase has two translation units main.cpp and coro2.cpp which
both include <coroutine>.

Linking the program with g++ (from the mingw-w64 toolchain built by the MSYS2
project on Microsoft Windows) fails with the following errors:

ld.exe: coro2.o:coro2.cpp:(.text+0x0): multiple definition of
`.weak._ZNSt7__n486122__dummy_resume_destroyEv._ZSt21is_constant_evaluatedv'; 

main.o:main.cpp:(.text+0x0): first defined here

ld.exe: coro2.o:coro2.cpp:(.data+0x0): multiple definition of
`.weak._ZNSt7__n486114__noop_coro_frE._ZSt21is_constant_evaluatedv'; 

main.o:main.cpp:(.data+0x0): first defined here


The issue is present in the versions of <coroutine> in the 10.2 release and the
10.3 release candidate, but not in the current head version in the gcc repo. It
is fixed in this commit:

  94fd05f1f76faca9dc9033b55d44c960155d38e9
  libstdc++: Define noop coroutine details private and inline [PR 95917]

Some discussion here: https://gcc.gnu.org/pipermail/gcc/2021-April/235305.html


More information about the Gcc-bugs mailing list