https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128824
Bug ID: 128824
Summary: Mangling error of transform_view members/operators
when template is instantiated with current_function
and with explicit reflection
Product: gcc
Version: 16.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
Source code:
The failing case is what happens with impl4, the others are for showing that
local lambda seems to be the culprit.
#include <meta>
#include <ranges>
consteval auto makeMember(int)
{
return std::meta::data_member_spec(^^int, {.name = "a"});
}
constexpr auto makeMember2 = [](auto) {
return std::meta::data_member_spec(^^int, {.name = "a"});
};
template <std::meta::info func>
struct ReplyImpl {
struct impl;
struct impl2;
struct impl3;
struct impl4;
consteval {
std::meta::define_aggregate(^^impl, std::views::single(1) |
std::views::transform(makeMember));
std::meta::define_aggregate(^^impl2, std::views::single(1)|
std::views::transform(makeMember2));
auto makeMember3 = [](auto) {
return std::meta::data_member_spec(^^int, {.name = "a"});
};
std::meta::define_aggregate(^^impl3,
std::views::single(makeMember3(1)));
std::meta::define_aggregate(^^impl4, std::views::single(1) |
std::views::transform(makeMember3));
}
};
struct S
{
void foo()
{
ReplyImpl<^^S::foo>{};
ReplyImpl<std::meta::current_function()>{};
}
};
https://godbolt.org/z/zbWrKcErr
Fails with:
In file included from test.cpp:2:
/usr/local/include/c++/16.2.1/ranges:2163:11: error: mangling of 'constexpr
bool std::ranges::operator==(const transform_view<single_view<int>,
ReplyImpl<^^S::foo>::<lambda()> static::<lambda(auto:56)> >::_Iterator<false>&,
const transform_view<single_view<int>, ReplyImpl<^^S::foo>::<lambda()>
static::<lambda(auto:56)> >::_Iterator<false>&) requires
equality_comparable<decltype(std::ranges::__access::__begin((declval<typename
std::__conditional<_Const>::type<const _Vp, _Vp>&>)()))>' as
'_ZNSt6ranges14transform_viewINS_11single_viewIiEEZN9ReplyImplILDmfnN1S3fooEvEEUlvE_clEvEUlT_E_E9_IteratorILb0EEFeqERKSB_SD_Q19equality_comparableIDTcl7__begincl7declvalIRNSt13__conditionalIXTL0__EE4typeIKS7_S7_EEEEEEE'
conflicts with a previous mangle
2163 | operator==(const _Iterator& __x, const _Iterator& __y)
| ^~~~~~~~
/usr/local/include/c++/16.2.1/ranges:2163:11: note: previous mangling
'constexpr bool std::ranges::operator==(const transform_view<single_view<int>,
ReplyImpl<^^S::foo()>::<lambda()> static::<lambda(auto:56)>
>::_Iterator<false>&, const transform_view<single_view<int>,
ReplyImpl<^^S::foo()>::<lambda()> static::<lambda(auto:56)>
>::_Iterator<false>&) requires
equality_comparable<decltype(std::ranges::__access::__begin((declval<typename
std::__conditional<_Const>::type<const _Vp, _Vp>&>)()))>'
/usr/local/include/c++/16.2.1/ranges:2163:11: note: a later '-fabi-version='
(or =0) avoids this error with a change in mangling
repeats for end(), operator[] and operator<=>.
Passing -fabi-version=0 does not avoid the error.
This issue seems to be triggered by instantiating the template once with
std::meta::current_function and once with typing the function name explicitely.
Commenting out either ReplyImpl<^^S::foo>{}; or
ReplyImpl<std::meta::current_function()>{}; makes the error go away. Also only
the local lambda seems affected, commenting out the instantiation of impl4
makes it compile, too.
I found https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125555 which seems to be
focused on a similar issue but happening with modules so I decided to file this
as a new bug.