test 1: template <int *p> struct A { A() {} }; int a; int main() { extern int a; A<&a>(); A<&::a>(); // is_same<A<&a>, A<&::a> >::value is false return 0; }
{standard input}: Assembler messages: {standard input}:20: Error: symbol `_ZN1AIXadL_Z1aEEEC1Ev' is already defined test 2: template <int &p> struct A { A() {} }; int a; int main() { extern int a; A<a>(); A< ::a>(); // is_same<A<a>, A< ::a> >::value is false return 0; } {standard input}: Assembler messages: {standard input}:20: Error: symbol `_ZN1AILZ1aEEC1Ev' is already defined test 3: template <int *p> struct A { A() {} }; namespace X { extern "C" int a; } extern "C" int a; int main() { A<&a>(); A<&X::a>(); // is_same<A<&a>, A<&X::a> >::value is false return 0; } {standard input}: Assembler messages: {standard input}:20: Error: symbol `_ZN1AIXadL_Z1aEEEC1Ev' is already defined -- Summary: Template pointer and reference arguments not always recognized as referencing to the same variable Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: nowak at xpam dot de GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44254