https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70413
Bug ID: 70413 Summary: Class template names in anonymous namespaces are not globally unique Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ers.trion at gmail dot com Target Milestone: --- Created attachment 38099 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38099&action=edit Example Source Code If a class template is defined twice with the same name inside of anonymous namespaces in different translation units and then used as a template template parameter, the two templates are not treated as having globally unique names. Example: invoke.hh: #include <iostream> void invoke_foo(), invoke_bar(); template<template<int> class T> void invoke_print() { T<0>{}.print(); } foo.cc: #include "invoke.hh" namespace { template<int> struct s { void print() { std::cout << "foo\n"; } }; } void invoke_foo() { invoke_print<s>(); } bar.cc: #include "invoke.hh" namespace { template<int> struct s { void print() { std::cout << "bar\n"; } }; } void invoke_bar() { invoke_print<s>(); } main.cc: #include "invoke.hh" int main() { invoke_foo(); invoke_bar(); } Compile with g++ -obug main.cc foo.cc bar.cc -std=c++11 Expected output: foo bar Actual output: foo foo Tested with GCC 5.3.0 on x86_64. Clang 3.7.1 gets this right. The source files are attached.