<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110364>110364</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[ASAN] ASAN changed program behavior of uninitialized array
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wr-web
</td>
</tr>
</table>
<pre>
reproduce: https://godbolt.org/z/6h7Kdn7Ya
bug code:
```cpp
#include <iostream>
void initializeArray(int* array, int size) {
for (int i = 0; i < size; ++i) {
array[i] = i * 2; // Proper initialization
}
}
int main() {
int* array = new int[10];
initializeArray(array, 5); // Only half of the array is initialized
// Access the uninitialized portion, which is technically safe,
// but the values might differ under AddressSanitizer.
std::cout << "Sixth element: " << array[5] << std::endl;
delete[] array;
return 0;
}
```
expected output: Sixth element: 0
unexpected output after using asan: Sixth element: -1094795586
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsVMuOszgTfZpiU-oIbAhhwQKSP5tfmhmpV7M0uACPHBvZJv11P_3IQHdn0l8UcSnXOXU7lPBejYaohqKF4pKIJUzW1W_u5Y26pLPyvXY0OyuXnoA3OIUwe-ANsCuw62hlZ3U4WDcCu34Aux6n8v_SlH8LSC-QNt0yYm9lhG4GOKbbv5_n3cK4Mr1eJCHws7I-OBI34P_bj9fr3SqJyqighFYf1Dgn3oGdlAnAGhTb6xmVCejVBwGrEMp2wyIiDtbh5o8KgV8wBd6uj-cNwFsE1gJr1Q9s_G0RilZBcVnxCmNgtuFiK_AvZ2dy30mKoKz5ZoHyshf09bBeY0o3oQyw04_Ij-WtUQ29rcaizVIoLsDbR6oN8tyjr-YUwKqHfP80-h0noQe0A4aJ9jDKP3DIZ_od2_Q9eb-iFvPgjrN1a9nsjG-T6qdIF6ifjOqF1u_oxUDAzj8IuyWsbHehF_J4U-MUUKphIIeLkeSwkdKR968iRvsgd_jm8EFGffGmt0uII41TBcZe1a8wIWm6kQlRvMDY5_HnQIttoKvti4eM1L_prSRNgbYPZSfgD9NyFBZnVmU9T_pT9Nsr_ZqpDyTRLmFe1sx-pLq7LubJGcUQYk-8MiMKL8xv0S9ZWuVlVRSnYyJrLiteiYTqrGRlwVlZ5clUd6fqOFS8EEUu2ClLZdef0mM2ZBXJjFiXqJqlLE8rdsryjGf80MmyrPKBy7KgfpAp5CndhNIHre-3uAMS5f1CdZal_JgnWnSk_bpYGFuVG0-BsbhnXB1BL90yeshTrXzw3zRBBb1upOa1-SM2O96xn4QZo8acHZ24YUeTuCvron7_q8J1NsnidP20rlSYlu7Q2xuwa4y2315mZ_-hPgC7rjl6YNe9iHvN_g0AAP__UYyGIw">