https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68049
Bug ID: 68049 Summary: template instantiation involving may_alias defines symbol twice Product: gcc Version: 5.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kretz at kde dot org Target Milestone: --- The following testcase fails to compile at -O0, but works at -O1 and higher (-std=c++11 is the only required compiler flag): template <typename T> struct Bar { using type = T; }; template <typename T> struct Foo { typedef typename Bar<T>::type alias_type [[gnu::may_alias]]; alias_type operator()() { return {}; } }; template <typename T> void print(T) {} int main() { print(Foo<int>()()); print(0); return 0; } The template instantiation of print(T) is done twice: /tmp/ccDEkoML.s: Assembler messages: /tmp/ccDEkoML.s:69: Error: symbol `_Z5printIiEvT_' is already defined With a recent GCC 6 snapshot I get: failure.cpp:19:1: error: Two symbols with same comdat_group are not linked by the same_comdat_group list. } ^ _Z5printIiEvT_/3 (void print(T) [with T = int]) @0x7faa000d75c0 Type: function definition analyzed Visibility: public weak comdat comdat_group:_Z5printIiEvT_ one_only previous sharing asm name: 2 References: Referring: First run: 0 Function flags: body Called by: main/0 (1.00 per call) Calls: _Z5printIiEvT_/2 (void print(T) [with T = Bar<int>::type]) @0x7faa000d7450 Type: function definition analyzed Visibility: public weak comdat comdat_group:_Z5printIiEvT_ one_only next sharing asm name: 3 References: Referring: First run: 0 Function flags: body Called by: main/0 (1.00 per call) Calls: failure.cpp:19:1: internal compiler error: symtab_node::verify failed 0x90a6e9 symtab_node::verify_symtab_nodes() ../.././gcc/symtab.c:1126 0x91d3d5 symbol_table::compile() ../.././gcc/cgraphunit.c:2377 0x920162 symbol_table::compile() ../.././gcc/cgraphunit.c:2536 0x920162 symbol_table::finalize_compilation_unit() ../.././gcc/cgraphunit.c:2562