[clang] [Clang] Fix an integer overflow issue in computing CTAD's parameter depth (PR #128704)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 25 05:21:36 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);
----------------
zyn0217 wrote:
Oh I realized we sometimes still want to use `Depth - 1` even if it is an explicit specialization (because it could be nested as in the first case, and the transformed depth should be 0) - so I think this is good enough?
https://github.com/llvm/llvm-project/pull/128704
More information about the cfe-commits
mailing list