<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/80925>80925</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[-Wunsafe-buffer-usage] Extra size arg in fixit for std::span initialization with constant size array
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
jkorous-apple
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jkorous-apple
</td>
</tr>
</table>
<pre>
Currently the fixit that transforms a local pointer initialized with constant size array uses 2-parameter std::span constructor to which it passes the array and it's size.
https://github.com/llvm/llvm-project/blob/main/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp#L52
```
void local_variable_qualifiers_specifiers() {
int a[10];
...
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:18}:"std::span<int const> p"
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:19-[[@LINE-2]]:19}:"{"
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:", 10}"
```
Idiomatic fixit should not repeat the size and instead rely on single parameter std::span constructor that take const size array.
No. 4 here: https://en.cppreference.com/w/cpp/container/span/span
Example:
```
void foo() {
int foo[5];
std::span<int> sp = foo;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVEuPpDYQ_jXuSwkEBTTdBw79GJRVVnvJIXsbFVA03nXbxDbz2F8fGZhXMqNkpZUQdFPU53p830fOyYtmrkRxFIjfvhtrJhfROCoWiKI4b2jyg7HVm9CmMd1jdZqsZe3VI_iBoZcP0oMfyIO3pF1v7NUBgTItKRiN1J4tSC29JCV_cAf30g_QGu08aQ9O_mAga-kRJscOMBrJ0pVDlvOdyA4iO7iR9JJip9YbC97A_SDbAaSHkVxIDMUsOKQ7kF5g6Wb0WCRnkRyW--D96AIo1gLri_TD1MStuQqslbp7ekSjNd-49QLrRplGYH0lqQXWrSJ9EVh7diH4B1_p9PWrwPqerI4m7ajnqJn6nm00ObpwNM_HRfM4ojuyUeglbsdRYPa5wNe1iW2yXvPfOyO7ZYy3d2QlNYpv_5pIyV6ydbdu5Hb5KXAncA-iPC6JAFJ7IFEc00QUZ5Gt7-M4fvpgaR9Ov92cfhfZIWwxkn6eCwac8hgLPIjyHC7EECiPgSzFUeTJ509fbqI0QAf0QxZ9FEl3IX9GfbNLkZ1CifNGRXYDYzjj15WGLwXso49Dz7UFgF9aQPZ8CibRx6GXAvAEabLivceF5f6pk-ZKXrar6txgJtWBNh4sjxwkOPCqqKAB7TxTB5bVIxgNTuqLYvhf-pr1TN95eftKpSuFvpgYchjYchjRW1XxzG_LPVvWLa_yug_yCbSvW6M9Sc1WYD2zYX286vTmga7Bi7LDfwmkN-bf_F8UEELFsXgtgRB6h4mBg24EkZ3npKevw0LeO37TVVm3z_a04SotkxLLHPPtZqi6fcMdlUXW5tSluxS37XaX7fY9c5pSkW9khQnmCSZlgkWSb-Ntv-Ok5A6bsi3TLhN5wleSKg42FBt72UjnJq52yR6LjaKGlVtdW_M9zMHVsW01W1czXZzIEyWddy8oXno123305zsuJYoz3Dx4S0-LvoDUK8l680-iPJs5eWn0h36-mayqftpv546cwHru-O8AAAD__2k794s">