Issue |
110364
|
Summary |
[ASAN] ASAN changed program behavior of uninitialized array
|
Labels |
new issue
|
Assignees |
|
Reporter |
wr-web
|
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
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs