https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96529
Bug ID: 96529 Summary: GCC applies C language linkage to instantiations from abbreviated function templates Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hstong at ca dot ibm.com Target Milestone: --- GCC appears to be treating the instantiated specialization of the abbreviated function template `g` as if it is a function named `g` whose name has C language linkage. [dcl.link] does not appear to apply language linkage to the names of specializations of function templates. Note: Nor does [dcl.link] apply language linkage to the names of templates (as opposed to the type that a specialization of the template would have). Compiler Explorer link: https://godbolt.org/z/s5875s ### SOURCE (<stdin>): extern "C" { void g(auto) {} void g(void) { g(42); } } ### COMPILER INVOCATION: g++ -std=c++20 -Wall -Wextra -pedantic-errors -xc++ - -c -o /dev/null ### ACTUAL OUTPUT: /tmp/cc2TjgyX.s: Assembler messages: /tmp/cc2TjgyX.s:25: Error: symbol `g' is already defined /tmp/cc2TjgyX.s: Error: .size expression for g does not evaluate to a constant ### EXPECTED OUTPUT: (clean compile) ### COMPILER VERSION INFO (g++ -v): Using built-in specs. COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++ COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head --enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl --enable-checking=release --disable-nls --enable-lto LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32 Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.0.0 20200805 (experimental) (GCC)