Skip to content

Template argument limit of 0x7fff in clang-21 onward #151784

@jameswplayer

Description

@jameswplayer

I noticed that clang TOT fails to compile variadic templates with argument count exceeding 0x7fff. I plugged a simple reproducer into godbolt and noticed that this behavior starts at clang-21 (i.e. clang-20 compiles successfully).

The simplest repro I came up with was to simply instantiate a std::index_sequence at various sizes, where the first static_assert() succeeds and the second one fails:

namespace std { typedef int a; template <typename b, b... c> struct d { constexpr a size() { return sizeof...(c); } }; template <typename b, b e> using f = __make_integer_seq<d, b, e>; template <a e> using make_index_sequence = f<a, e>; } // namespace std int main() { constexpr unsigned SeqLength = 0x7fff; std::make_index_sequence<SeqLength> Seq; static_assert(Seq.size() == SeqLength); { constexpr unsigned SeqLength = 0x8000; std::make_index_sequence<SeqLength> Seq; static_assert(Seq.size() == SeqLength); } } 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions