<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60053>60053</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
avoid `modernize-avoid-c-arrays` warning with templates that deduce array length
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
firewave
</td>
</tr>
</table>
<pre>
```cpp
#include <cstdint>
template<typename T, int size>
std::size_t arrayLen(const T (& /*unused*/)[size])
{
return size;
}
```
```
<source>:4:28: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays]
std::size_t arrayLen(const T (& /*unused*/)[size])
^
```
https://godbolt.org/z/bvWbTqP1f
In our case this is used to get the length of a string literal. It doesn't make sense to use `std::array` for that.
So before C++17 you can only suppress this as `std::string_view`, which would allow to get rid of this, is not yet available.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0U02P4zYM_TX0hUjgSLbjHHzIxwRYoIcCHaDHhSwxsVpFciU6QebXF3KS7XTQHhcwbIkmqfcen1RK9uyJOqh3UB8KNfEQYneykW7qSkUfzL2Dpnw8ehyhPEC5BSGt124yhCD3OrGxnkG-Pf_Ob6bL6BQTyD3fR_LqQvgOYo_WMyb7QT_yExuQW5DbHP3OqGJU91_Ig2h18InxHUG0IBoEcQSxnfyUyIDYztsN1Lu5XX3ImweC9e6xQESMxFP0zyN3r4TDc_Hi9hn616DcpzBFPSOW2wrkVrQgt3hT0Vt_zksT0AdGQ9qpSLhfJL47elBJmfWUCH8QncMg9yDf0PrEpAxCvbsEQ9HbD1qoa7BmoRfP-vrws5RCqN_-k_TAPKZ8WK48noPpg-NliGcQxw8Qx_76e__-16-r02fhvnkMU0StEiEPNqFNmbhBDngmRh4IHfkzDxhOqDBxtP6MzjJF5Zb4jdEESh7EmvGi_iRM5HOvMOsHTflFwqbEU4jIg-LlZyC_BezpFPIkQOxA7FZrvIcJtfIYvLtjmsYxUkoPmCr9q_cD1verpVvWQ-zxNlg94C1MzqByLtxejKI1mUruMns7zTa4E6O6KutU72hZmE6ajdyogrpVs5Zt2Wyqthg6rZr6pFcnoeuyWqtm1feibPu2qk15EloUthOlkOVqVa9aIUS7rKpKrJu239C6b_q-gaqki7Ju6dz1kqdT2JQm6pqyrGXhVE8uve527HLSop_OCarS2cTpnzK27KibbZel-F8nNuXL9XizPODrlqd5BmjITPpp--ekiym67oubLA9Tv9ThAuKYITw_izGGP0gziONMI4E4zkz-DgAA__-bJW4E">