[clang] [Clang] Fix an integer overflow issue in computing CTAD's parameter depth (PR #128704)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 25 04:48:09 PST 2025
================
@@ -377,8 +377,12 @@ struct ConvertConstructorToDeductionGuideTransform {
if (NestedPattern)
Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
auto [Depth, Index] = getDepthAndIndex(Param);
+ assert(Depth ||
+ cast<ClassTemplateSpecializationDecl>(FTD->getDeclContext())
+ ->isExplicitSpecialization());
NamedDecl *NewParam = transformTemplateParameter(
- SemaRef, DC, Param, Args, Index + Depth1IndexAdjustment, Depth - 1);
+ SemaRef, DC, Param, Args, Index + Depth1IndexAdjustment,
+ Depth ? Depth - 1 : 0);
----------------
hokein wrote:
IIUC, for fully explicit specializations where the template parameter list is empty `<>`, they don't contribute to the depth. This makes me think we should use `Depth` directly if `FTD->getDeclContext()` is an explicit specialization?
Would it be possible the Depth is not 0 in that case? an explicit template specialization is inside a template class?
https://github.com/llvm/llvm-project/pull/128704
More information about the cfe-commits
mailing list