Bug 99907 - (On MS Windows) Multiple definition errors with <coroutine> included in two translation units
Summary: (On MS Windows) Multiple definition errors with <coroutine> included in two t...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 10.2.0
: P3 normal
Target Milestone: 11.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-04 11:38 UTC by R Copley
Modified: 2024-01-17 10:11 UTC (History)
2 users (show)

See Also:
Host:
Target: mingw-w64
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
testcase (947 bytes, application/x-tar)
2021-04-04 11:38 UTC, R Copley
Details

Note You need to log in before you can comment on or make changes to this bug.
Description R Copley 2021-04-04 11:38:25 UTC
Created attachment 50506 [details]
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
Comment 1 Jonathan Wakely 2024-01-17 10:11:34 UTC
The GCC 10 release series is no longer supported, so this is fixed in all supported release series.