<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/150426>150426</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
extent_v in static_assert not detecting inferred array length with rest argument expansion before use
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mstange
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/c61WhKbaz
The `static_assert` below fails in clang 20.1.0, but passes in gcc 15.1 and msvc 19:
```cpp
#include <stdio.h>
#include <type_traits>
template <int... ArgValues>
struct MyTemplateStruct {
static constexpr int values[] = {ArgValues...};
};
int main() {
using ConcreteStruct = MyTemplateStruct<5>;
// printf("test: %d\n", ConcreteStruct::values[0]);
// This assertion starts passing if you uncomment the above printf
static_assert(std::extent_v<decltype(ConcreteStruct::values)> == 1,
"should detect one element in values member");
return 0;
}
```
Error message with clang:
```
<source>:15:19: error: static assertion failed due to requirement 'std::extent_v<const int[], 0> == 1': should detect one element in values member
15 | static_assert(std::extent_v<decltype(ConcreteStruct::values)> == 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:15:67: note: expression evaluates to '0 == 1'
15 | static_assert(std::extent_v<decltype(ConcreteStruct::values)> == 1,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
1 error generated.
```
The first template argument to `extent_v` is `const int[]` without the printf, and `const int[1]` with the printf.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVU1v4zYQ_TX0ZbACRVofPuigteNL0VOD9hhQ0lhiIZEqOXLiPfS3F6ScOE62RfdQVDBsWhzOvHnzZqi8171BrFj2lWWHjVposK6aPCnT46ax3aUaiGbPZM3EkYljb7vGjpRY1zNx_MbEsc3T34afGvWN8Zrx-nFAYDn3pEi3T8p7dMRyDg2O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