================ @@ -1650,6 +1665,23 @@ namespace { return inherited::TransformTemplateArgument(Input, Output, Uneval); } + std::optional<unsigned> ComputeSizeOfPackExprWithoutSubstitution( + ArrayRef<TemplateArgument> PackArgs) { + // Don't do this when rewriting template parameters for CTAD: + // 1) The heuristic needs the unpacked Subst* nodes to figure out the + // expanded size, but this never applies since Subst* nodes are not + // created in rewrite scenarios. + // + // 2) The heuristic substitutes into the pattern with pack expansion + // suppressed, which does not meet the requirements for argument + // rewriting when template arguments include a non-pack matching against + // a pack, particularly when rewriting an alias CTAD. + if (TemplateArgs.isRewrite()) + return std::nullopt; ---------------- zyn0217 wrote:
It's not that hard to contrive an example to demonstrate the difference (though invalid): ```cpp template < typename... _Types > struct variant { template <int N = sizeof...(_Types)> variant(_Types...); }; template <class T> using AstNode = variant<int, int, int>; // <-- Note here! AstNode tree(42, 43, 44); ``` We still would end up here with a rewrite MLTAL = {int, int, int}, so we fall through to the normal way and crash because we don't have a valid SubstIndex for a pack https://github.com/llvm/llvm-project/pull/132061 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits