<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92191>92191</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
-Wunsafe-buffer-usage erroneously warns on array accesses into compile-time string constants, but only in function scope
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pkasting
</td>
</tr>
</table>
<pre>
Compiling the following code with `-Wunsafe-buffer-usage` unexpectedly emits a warning:
```
constexpr char kAbc[] = "abc";
static_assert(kAbc[3] == '\0'); // OK
static_assert("abc"[3] == '\0'); // OK
void f() {
static_assert(kAbc[3] == '\0'); // OK
static_assert("abc"[3] == '\0'); // WARNING
}
```
Live repro: https://godbolt.org/z/c6jhdvPTb
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysU02L2zAQ_TXjy5AgS7G9OfiQ3ZBSWralFPZYZHlsa1eRjEZONv31JY5hod1LS4VgGKT35s2XZra9J6qhuIdin-kpDSHW44vmZH2fNaG91A_hOFpnfY9pIOyCc-F89UxoCc82DQilWD1NnnVHq2bqOoqriXVPUAqcPL2OZBK17oJ0tIlR41lHb30PagdiD2IHpVju7JrgOdHrGNEMOuLLrjE3gQhqjyClbgxICer-9p-TTtb80MwUE8i7BaAWxA1UQfEgrkZuQd0jgjyAPOCXT4uEd5neYv0T3SnYFruZZ4tQLXLx_-nFP7j-WvHT7tvjx8cPC2u1f7cjn-2JMNIYA6gdDimNfG3ezNCHtgkurUPsQR5-gjyY8nloT1-_N1lbq3artjqjOq_yopLbMlfZUOclVV1ViLuNykVTik0pqkqJirTuOip0Zmsp5EYU-Uaq61mTuSOhVGGU0KSrEjaCjtq6tXOn4zV2Zpknqrcy3-aZ0w05nsdaSk9nnB_nquyzWF8xq2bqGTbCWU78xpJsclS_O85IMQZPYWJ3mUeYMXjUMeoLamOImRitTwHNvDK0SvZIyCne1sVz0j4xyAdspoTBuwtaj93kTbLBI5swUjZFV_9WYJuGqVmbcAR5uApdzGqM4ZlMAnmY02OQhzn9XwEAAP__5xsifQ">