<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/120167>120167</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] Matrix types are currently not supported in constant evaluation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
constexpr
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Sirraide
</td>
</tr>
</table>
<pre>
We support vector types, so supporting matrices as well would make sense, even though it sounds like it’d be quite a bit of work as it would probably involve adding a new `APValue` kind.
As an example, this (https://godbolt.org/z/WE84hhYvP):
```c++
template <typename T>
constexpr bool f() {
T t = T();
return true;
}
using M = int [[clang::matrix_type(4, 4)]];
static_assert(f<M>());
```
doesn’t work currently:
```console
<source>:9:15: error: static assertion expression is not an integral constant expression
9 | static_assert(f<M>());
| ^~~~~~
<source>:3:11: note: non-literal type 'int __attribute__((matrix_type(4, 4)))' cannot be used in a constant expression
3 | T t = T();
| ^
<source>:9:15: note: in call to 'f<int __attribute__((matrix_type(4, 4)))>()'
9 | static_assert(f<M>());
| ^~~~~~
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VM1u4zYQfprRZbCGTFqWdNBB8c8twAINuujJoMSxzYYmVXLkJD302QtKdtKm2EVRoAQBCaT46fvhjIrRnBxRA8UDFNtMjXz2ofnJhKCMpqzz-q35RhjHYfCB8Uo9-4D8NlAEscHo71vGnfCiOJieIqqIL2QtvvjRaryoZ8JILlI6QldyyGc_ns5oGKMfnY5ozTOhYdgJqHKoa40d4W-jYUKFnWH0R3zx4TlBG74BD8F3qrNvaNzV2yuh0jrxUOjoBWGdt19_VnYkWOf4bJxeQN5C3rYRlUN6VZfBTpT4bCKCqM7MQwTZgtiD2J-87rzlhQ8nEPvfQey_7arV-fzL9SuIOn2Wt7DO59mDeEgzb5kug1VMCHKTfHLqQvgEcgd523sXmV6HgJ33Fo8gKhA1QpkOIiI-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