On Wed, 2023-08-30 at 20:53 +0800, Xi Ruoyao via Gcc-help wrote: /* snip */ > -fsanitize=undefined cannot detect any uninitialised use. OTOH - > fsanitize=memory is capable: > > $ clang++ t.cc -fsanitize=memory > $ ./a.out > ==969846==WARNING: MemorySanitizer: use-of-uninitialized-value > #0 0x5603db7b65f7 in cl(d) (/home/xry111/a.out+0xb55f7) > #1 0x5603db7b6709 in k() (/home/xry111/a.out+0xb5709) > #2 0x5603db7b67d8 in main (/home/xry111/a.out+0xb57d8) > #3 0x7ff2d9c27f59 in __libc_start_call_main /home/xry111/sources/lfs/glibc-2.38/csu/../sysdeps/nptl/libc_start_call_main.h:58:16 > #4 0x7ff2d9c28024 in __libc_start_main@GLIBC_2.2.5 /home/xry111/sources/lfs/glibc-2.38/csu/../csu/libc-start.c:360:3 > #5 0x5603db71f2d0 in _start /home/xry111/sources/lfs/glibc-2.38/csu/../sysdeps/x86_64/start.S:115 > > SUMMARY: MemorySanitizer: use-of-uninitialized-value (/home/xry111/a.out+0xb55f7) in cl(d) > Exiting > > But unfortunately the memory sanitizer is only supported by Clang, not > GCC :(. For the record https://gcc.gnu.org/PR66487 is the enhancement ticket for adding MSAN support to GCC, but it looks like nobody has really worked on it. -- Xi Ruoyao <xry111@xxxxxxxxxxx> School of Aerospace Science and Technology, Xidian University