我使用 GCC 10 标志构建-fsanitize=address并且可以很好地运行程序,但是如果我在 Valgrind 下运行它会显示 Asan 错误:
==477229== Memcheck, a memory error detector
==477229== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==477229== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==477229== Command: ./a.out
==477229==
==477229==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
==477229==
==477229== HEAP SUMMARY:
==477229== in use at exit: 0 bytes in 0 …Run Code Online (Sandbox Code Playgroud)