https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120617
Bug ID: 120617
Summary: ICE: in convert_nontype_argument, at cp/pt.cc:7977
Product: gcc
Version: 15.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: aandrejevas5 at gmail dot com
Target Milestone: ---
Hello. My GCC version is 15.1.0. But I tested on godbolt on trunk and saw the
same error – https://godbolt.org/z/rh9j5qcWo.
Source code:
template<class T>
struct type_identity {
using type = T;
};
template<class A>
consteval void test() {}
template<auto V>
constexpr decltype(V) const_v = V;
template<auto V>
using type_in_const_t = typename decltype(V)::type;
template<auto F>
consteval bool is_constexpr_friendly() {
return (requires { const_v<(F(), true)>; });
}
template<class T>
concept movable_immediately_constructible = is_constexpr_friendly<[] { return
T{}; }>();
struct value_getter {
template<movable_immediately_constructible T>
consteval operator T() { return T{}; }
};
template<class T>
constexpr T default_v = value_getter{};
template<class T>
constexpr type_identity<T> type_v = default_v<type_identity<T>>;
template<class... F>
struct overload : F... {
using F::operator()...;
};
template<class F>
using function_t = type_in_const_t<overload{
([]<class R, class... A>(type_identity<R(*)(A...)>) { return
type_v<R(A...)>; }),
([]<class T, class R, class... A>(type_identity<R(T:: *)(A...)>) {
return type_v<R(A...)>; }),
([]<class T>(this auto lambda, type_identity<T>) { return
lambda(type_v<decltype(&T::operator())>); })
}(type_v<F>)>;
int main() {
test<function_t<decltype([] mutable {})>>();
test<function_t<decltype([] static {})>>();
}
Error:
$ g++ -o bin/main.exe main.cpp -Wall -Wextra -std=c++26
main.cpp: In substitution of 'template<class T> requires
movable_immediately_constructible<T> consteval value_getter::operator T() [with
T = type_identity<main()::<lambda()> >]':
main.cpp:29:13: required from 'constexpr const
type_identity<main()::<lambda()> > default_v<type_identity<main()::<lambda()> >
>'
29 | constexpr T default_v = value_getter{};
| ^~~~~~~~~
main.cpp:32:37: required from 'constexpr const
type_identity<main()::<lambda()> > type_v<main()::<lambda()> >'
32 | constexpr type_identity<T> type_v = default_v<type_identity<T>>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:44:3: required by substitution of 'template<class F> using
function_t = type_in_const_t<overload<...auto...>{<lambda>, <lambda>,
<lambda>}(type_v<F>)> [with F = main()::<lambda()>]'
44 | }(type_v<F>)>;
| ^~~~~~~~~
main.cpp:48:18: required from here
48 | test<function_t<decltype([] static {})>>();
| ^~~~~~~~~~~~~~~~~~~~~~
main.cpp:21:86: internal compiler error: in convert_nontype_argument, at
cp/pt.cc:7977
21 | concept movable_immediately_constructible = is_constexpr_friendly<[] {
return T{}; }>();
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <https://github.com/msys2/MINGW-packages/issues> for instructions.