Repository navigation
P3865R3 CTAD through a template template parameter: internal error when the deducing cast is inside an alias template #173
stevensudit-corvid
started this conversation in
Issue Triage - Compilation
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
The front end supports class template argument deduction through a type template template parameter (EDGcpfe/28857, with follow-up work in EDGcpfe/29001). One case looks like it is not covered yet: the deducing cast,
C(0), is thedecltypeoperand of an alias template, and the alias is named in arequires-expression. That stops the compilation with an internal error.gcc and clang accept the code. I ran into it through
std::ranges::to<std::vector>()with libstdc++ 16, whose implementation has this shape.Reproducing Source Code
Command-line Options
cpfe --c++23 repro.cpp
Type of Issue
[Front End] I do not care but this code CRASHES the compiler.
Additional Details
The diagnostic, at 158320e (version 7.0):
--c++20and--c++26give the same result, and so do the GNU, Clang and Microsoft modes. With braces in the alias,decltype(C{0}), the assertion is at exprutil.c line 15962 inprep_generic_operand_full.The same alias gives an ordinary error in two other places. Both files are valid C++17, and gcc and clang accept them, but
--c++17through--c++26under cpfe reject them in every mode.As a function template's return type:
As a default template argument:
These uses compile:
requires { C(0); },decltype(C(0)) to();andclass = decltype(C(0)).requires { typename ded<C>::type; }.ded<vec> x(0);, or as a member type or a variable template's type.requires-expression in a concept.What I saw in a
linux-gcc-debugbuild, which may save you a step. For a placeholder that names a template template parameter,deduce_class_template_argsasksbound_template_template_argument(templates.c:46128) for the template bound to the parameter's symbol. When the alias is substituted throughcopy_type_with_substitutionanddecltype_of_expr_with_substitution, the placeholder still names the alias's own parameterC, and that symbol'sargument_templateisCitself. The answer is therefore "still dependent" (overload.c:30971).scan_functional_notation_type_conversionthen takes its dependent branch and callsgeneric_cast_operand(expr.c:31183), which assertsis_template_dependent_context(). The two error cases reach the same "still dependent" answer fromsubstitute_template_arguments. The direct use,ded<vec> x(0);, scans the alias from its tokens ininstantiate_template_alias, and there the parameter is bound tovec.The libstdc++ 16 form is
std::views::iota(0, 3) | std::ranges::to<std::vector>(). It hits the same assertion at line 9712 of<ranges>, onif constexpr (requires { typename _DeduceExpr1<_Cont, _Rg, _Args...>; }).nvcc 13.3, which embeds EDG 6.8, compiles all three files, so this behavior is newer than 6.8. I have not bisected it.
Reproducing (Standard) Configuration(s)
linux-gcc-release
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions