[clang] [clang] CTAD: Track template template type parameters that referenced in (PR #85405)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 20 08:06:37 PDT 2024


ilya-biryukov wrote:

> This issue comes from a bug in the implementation where we missed to handle the template template parameter. The resulting crash is a manifestation of this problem.

Sure, that's obvious. I see that we access the vector by the template parameter index and the access is out-of-bounds.
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?

> I think it also affect correct code, I tried to come up with such example (which triggers the CTAD on template template parameters), but no luck :(

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?
```cpp
template <class T>
class Container {};
Bar t = Foo<K<Container>>();
```


https://github.com/llvm/llvm-project/pull/85405


More information about the cfe-commits mailing list