https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87207
Bug ID: 87207 Summary: ODR issue with static functions and lambda templates Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: blastrock at free dot fr Target Milestone: --- Created attachment 44652 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44652&action=edit Small reproduction test case I have a library that instantiates a chain of class templates and lambda templates. I have two files with a static function that has the same name, but by being static they should not interfere with each other. It seems that gcc generates and exports a symbol depending on this static function, and the linker only keeps one instance of it, making the other instantiation wrong. I have prepared a small reproduction test case. The String class is initialized to 0 and asserts that it still contains 0 in its destructor. Moreover, it prints the addresses where it is constructed and destroyed. When compiling this project with any GCC version from Ubuntu (tested on Ubuntu 18.04, with GCC 6, 7 and 8), it will crash. I couldn't reproduce the issue on Debian. I tried adding the stack-protector and fortify flags that are enabled by default on Ubuntu but couldn't reproduce the bug on Debian. The output is: new 0x7ffcb217a6a8 new 0x7ffcb217a648 delete 0x7ffcb217a660 terminate called after throwing an instance of 'int' Aborted (core dumped) Removing the `async_resumable` instantiation from bunny.cpp (which is code that is never called) will make main.cpp work. The test case is attached.