https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71968
Bug ID: 71968 Summary: Type with no linkage in signature: symbols for unique entities link together Product: gcc Version: 7.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hstong at ca dot ibm.com Target Milestone: --- GCC produces symbols for entities which cannot possibly be referenced from another translation unit in such a way that distinct entities link together. In the following program, the templates in question are neither equivalent nor functionally equivalent. Online compiler: http://melpon.org/wandbox/permlink/YXAMmVBat8N2aXRe ### SOURCE (a.cc): extern "C" void abort(); void bar(); namespace { struct A { A(int); char sizer[1]; }; } template <typename T> void foo(char (*)[sizeof A(T(0))]) { static unsigned cnt = 0; if (cnt++) abort(); } int main(void) { bar(); foo<int>(0); } ### SOURCE (b.cc): extern "C" void abort(); namespace { struct A { A(int); char sizer[2]; }; } template <typename T> void foo(char (*)[sizeof A(T(0))]) { static unsigned cnt = 0; if (cnt++) abort(); } void bar() { foo<int>(0); } ### COMMANDS: g++ -c -o a.o -std=c++11 a.cc g++ -c -o b.o -std=c++11 b.cc g++ -o a.out a.o b.o ./a.out ### EXPECTED OUTPUT: rc=0 ### ACTUAL OUTPUT: (aborts) ### COMPILER VERSION INFO (g++ -v): Using built-in specs. COLLECT_GCC=/usr/local/gcc-head/bin/g++ COLLECT_LTO_WRAPPER=/usr/local/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /home/heads/gcc/gcc-source/configure --prefix=/usr/local/gcc-head --enable-languages=c,c++ --enable-lto --disable-multilib --without-ppl --without-cloog-ppl --enable-checking=release --disable-nls Thread model: posix gcc version 7.0.0 20160721 (experimental) (GCC)