g++ (Compiler-Explorer-Build) 11.0.0 20201205 (experimental) command line flags: -std=c++17 -pedantic-errors ``` template <auto& ref> struct S {}; template <typename T> void foo(T) {} extern const int arr[]; // arr is const int[] void bar(S<arr> s) { foo(s); } const int arr[2] = {1,2}; // arr is const int[2] void baz(S<arr> s) { foo(s); } ``` source>:19:1: error: Two symbols with same comdat_group are not linked by the same_comdat_group list. 19 | } | ^ _Z3fooI1SIL_Z3arrEEEvT_/4 (void foo(T) [with T = S<arr>]) @0x7f7216d81330 Type: function definition analyzed Visibility: no_reorder public weak comdat comdat_group:_Z3fooI1SIL_Z3arrEEEvT_ one_only previous sharing asm name: 3 References: Referring: Function flags: body Called by: _Z3baz1SIL_Z3arrEE/2 Calls: _Z3fooI1SIL_Z3arrEEEvT_/3 (void foo(T) [with T = S<arr>]) @0x7f7216d81220 Type: function definition analyzed Visibility: no_reorder public weak comdat comdat_group:_Z3fooI1SIL_Z3arrEEEvT_ one_only next sharing asm name: 4 References: Referring: Function flags: body Called by: _Z3bar1SIL_Z3arrEE/0 Calls: <source>:19:1: internal compiler error: symtab_node::verify failed 0x1c39f09 internal_error(char const*, ...) ???:0 0xacca22 symtab_node::verify_symtab_nodes() ???:0 0xae8def symbol_table::finalize_compilation_unit() ???:0 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Compiler returned: 1 godbolt: https://godbolt.org/z/bKc1c1
Probably a dup of bug 91241.
This one started with r7-4431-g4a826ca6feb3c7ec, it was rejected before that: pr98163.C:1:17: error: ‘auto’ parameter not permitted in this context template <auto& ref> ^~~ pr98163.C:10:15: note: invalid template non-type parameter void bar(S<arr> s) { ^ pr98163.C:17:15: note: invalid template non-type parameter void baz(S<arr> s) { ^
and without the checking one gets an assembler error: $ g++ pr98163.C -c -std=c++17 -pedantic-errors /tmp/cclBTXg2.s: Assembler messages: /tmp/cclBTXg2.s:70: Error: symbol `_Z3fooI1SIL_Z3arrEEEvT_' is already defined so the checking really makes sense.
Other example in the same spirit, but not using array of unknown bound: ``` template <auto&> struct S {}; template <typename T> void foo(T) {} int i; constexpr const int& iref = i; template void foo(S<i>); template void foo(S<iref>); ```
Another similar example: ``` struct foo { }; static constexpr const foo obj{}; template <class T, const foo& OBJ> struct wrapper{ }; wrapper<foo, obj> returned() { return {}; } template <class T, const foo& OBJ> constexpr inline void f(wrapper<T, OBJ>) { } int main() { f<foo, obj>({}); f(returned()); return 0; } ``` This fails on GCC 14.1 and upwards with assembler error, and with ICE when checking is enabled up to GCC 14.2: ``` Executor x86-64 gcc 14.2 (C++, Editor #1) x86-64 gcc 14.2 x86-64 gcc 14.2 Compiler options for execution -pedantic-errors -fchecking Execution arguments... Could not execute the program Build failed Compiler returned: 1 Compiler stderr <source>:24:1: error: Two symbols with same comdat_group are not linked by the same_comdat_group list. 24 | } | ^ _Z1fI3fooL_ZL3objEEv7wrapperIT_XT0_EE/4 (constexpr void f(wrapper<T, OBJ>) [with T = foo; const foo& OBJ = (& obj)]) Type: function definition analyzed Visibility: semantic_interposition no_reorder public weak comdat comdat_group:_Z1fI3fooL_ZL3objEEv7wrapperIT_XT0_EE one_only previous sharing asm name: 3 References: Referring: Function flags: body Called by: main/2 Calls: _Z1fI3fooL_ZL3objEEv7wrapperIT_XT0_EE/3 (constexpr void f(wrapper<T, OBJ>) [with T = foo; const foo& OBJ = obj]) Type: function definition analyzed Visibility: semantic_interposition no_reorder public weak comdat comdat_group:_Z1fI3fooL_ZL3objEEv7wrapperIT_XT0_EE one_only next sharing asm name: 4 References: Referring: Function flags: body Called by: main/2 Calls: <source>:24: confused by earlier errors, bailing out ```