| Issue |
87162
|
| Summary |
MemorySanitizer does not detect partially initialized values
|
| Labels |
compiler-rt:msan
|
| Assignees |
|
| Reporter |
wheatman
|
The following code when compiled with `-O1` or above does not provide any errors even though some parts of x have not been initialized.
```cpp
#include <stdint.h>
#include <string.h>
int main(int argc, char **argv) {
uint32_t x;
uint32_t y = argc;
memcpy(&x, &y, 1);
return x;
}
```
The code does give an error when compiled with `-O0`
```
==1==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x555f7308f65a in main /app/example.cpp:8:5
#1 0x7f3c4fc29d8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: c289da5071a3399de893d2af81d6a30c62646e1e)
#2 0x7f3c4fc29e3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f) (BuildId: c289da5071a3399de893d2af81d6a30c62646e1e)
#3 0x555f72ff52e4 in _start (/app/output.s+0x322e4)
SUMMARY: MemorySanitizer: use-of-uninitialized-value /app/example.cpp:8:5 in main
Exiting
```
this is all with post 18 trunk(7de82ca369b5e9114636420a16e1c5d25283421d)
https://godbolt.org/z/TYePeb5r4
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs