https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127331
Bug ID: 127331
Summary: [reflection] Mangling conflict when using annotation
reflection as a template argument
Product: gcc
Version: 16.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mhvs1122 at gmail dot com
Target Milestone: ---
When passing a std::meta::info object that reflects an annotation as a NTTP,
GCC emits a mangling conflict error upon multiple instantiations of the same
function. This is a regression, as the exact same code gives compiler
generation error on GCC 16.2 with "-fabi-version=21" and build error with "19"
and "20" but works with GCC 16.1.
On compiler explorer: https://godbo.lt/z/foo4179xE
Source code:
#include <meta>
template<auto V> void Parse() {}
[[ =1 ]] std::string_view name{ "AiKathG" };
constexpr auto k_annots{
std::define_static_array(std::meta::annotations_of(^^name)) };
int main() {
Parse<k_annots[0]>(); // First instantiation
Parse<k_annots[0]>(); // Compiler error triggered here
return 0;
}
Output with "-fabi-version=21":
<source>: In function 'void Parse() [with auto V = ^^[[=1]]]':
<source>:3:23: error: mangling of 'void Parse() [with auto V = ^^[[=1]]]' as
'_Z5ParseITnDaLDman_EEvv' conflicts with a previous mangle
3 | template<auto V> void Parse() {}
| ^~~~~
<source>:3:23: note: previous mangling 'void Parse() [with auto V = ^^[[=1]]]'
<source>:3:23: note: a later '-fabi-version=' (or =0) avoids this error with a
change in mangling
Compiler returned: 1
Output with "-fabi-version=19" and "20":
ASM generation compiler returned: 0
/tmp/ccTu2m1I.s: Assembler messages:
/tmp/ccTu2m1I.s:61: Error: symbol `_Z5ParseITnDaLDman_EEvv' is already defined
Execution build compiler returned: 1
Build failed