<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/91884>91884</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
C++26 Pack-indexing have BUG
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Mq-b
</td>
</tr>
</table>
<pre>
```cpp
auto print(auto&&...args){
[&]<std::size_t... idx>(std::index_sequence<idx...>){
std::print("{} {} {} {}",args...[idx]...);
}(std::make_index_sequence<sizeof...(args)>());
}
int main(){
print(1,2,3,"🤣");
}
```
OK ! [godbolt..](https://godbolt.org/z/3KWWjb39T)
```cpp
auto print(auto&&...args){
[&]<std::size_t... idx>(std::index_sequence<idx...>){
(std::print("{} ",args...[idx]), ...);
}(std::make_index_sequence<sizeof...(args)>());
}
int main(){
print(1,2,3,"🤣");
}
```
Error ! [godbolt..](https://godbolt.org/z/Gfv5xd7f1)
If changed to:
```cpp
void print_one(auto& arg){
std::print("{} ", arg);
}
void print(auto&&...args){
[&]<std::size_t... idx>(std::index_sequence<idx...>){
(::print_one<decltype((args...[idx]))>(args...[idx]), ...);
}(std::make_index_sequence<sizeof...(args)>());
}
```
OK ! [godbolt..](https://godbolt.org/z/Es43szsnG)
Seems to be moving out? But it doesn't matter. It's a BUG.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzclV9v2jwUxj_NyY1FlBzH-XORCwhNVVWv3ld6N_US2bEBtyGmscNoP_3kUArt2CZNk1YNIWJkn-c8v5wHwq3Vq06pEtgM2Dzgg1ubvvzncSICYeRTCWl0eDfbLURziKZ8cIZse905wNx_AUwB0zAMeb-ygAVks8NJQgjxupgCmwOtrJNAp0CnVj-rhQvDkGi5B3oFmL_u6U6q_cKqx0F1jQJaabkPw3A89Vbav17LjoYA0R_K5uTSxe9i5X16STbz7dncr7EAem7bnz2Z2vAHtfjGmccwy7E6P7KPMH5xJujFDovxU3eObLjuXg6eIx0pYsDKO6WAlfdcR1DUME1gSkeES9rHQZ23-veWAMZ-CCsjhWmdp_Zka-e21rNhDVgfN02_AqyfAWt6e3d3L2jxyfc6E_zgcTivvJCIi9Mfh1WRvzcEV31v-l_MwfVyx_YyW8bvcnCzJM2adysliTO-_ocZ2RktD1gL06lTTgj3jd7S_3R-x6Lv3NhTr4-RxzOYEZ5WUjWte9qqkS2_GMeXCP3xqP7W_5Qrm1D7bLvrd1n6X6mNJc4QocjG7HS3ImZwQGsyGxzRjkijbAeY-V-Mc6oPyY0DzCzhZPb5OgxkSWVBCx6oMs5ixhATlgbrUhQiY2zJ5ZJnyFKRiUJKSkWT5rGSCQ90iREmEYsxTqKIsTAqWNpkIm8EjfNoWUASqQ3Xbdi2u41HCbS1gyqLOM-ToOVCtXZ8dCJ26gsZN31K2TzoS18zEcPKQhK12jp7UnHataqsAGeAM0zJf7x5mIzz8vRrvlOeLBj6tnx3V7VbDyJszAaw9nIvl8m2N_eqcYD1aMIC1qPJrwEAAP__ZrgedA">