[clang] [clang] CTAD: Track template template type parameters that referenced in (PR #85405)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 27 02:52:43 PDT 2024
hokein wrote:
> But my question is: how does the missing call to `MarkAppeared()` leads to the out-of-bounds access? Do we allocate a vector that has the size of `max(Index)` and expect that we have previously marked all template parameters mentioned in the type?
Yes, almost. The template parameter list of the synthesized deduction guide consists of two parts:
1) the template parameters of the alias template that appeared in the deductions;
2) the template parameters of the underlying template (RHS of the alias) that were not deduced;
MarkAppeared() performs the step 1, the crash is that we don't track the template template type parameters, thus we miss this kind of template parameter in the list, and we have a reference to it in the synthesized deduction guide declaration which could lead to an out-of-bounds access (for this particular case, the template parameter list is empty).
> I have tried to turn your example into valid code and it [also crashed](https://gcc.godbolt.org/z/38c3dKG7b). Could we add it to the tests?
Great, thanks! Added.
https://github.com/llvm/llvm-project/pull/85405
More information about the cfe-commits
mailing list