对于-fsanitize选项中的gcc,如何同时使用'address'和'leak'?

For gcc in the -fsanitize option, how to use ‘address’ and ‘leak’ together?

gcc 版本为 5.4.0

我想这样用:-fsanitize=address,leak

好吗?

只需将 -fsanitize=address-fsanitize=leak(作为单独的程序参数)传递给 gcc。阅读关于 Invoking GCC and the section on Instrumentation Options 的章节。

也考虑使用 valgrind 程序。

不要忘记用 -Wall -Wextra -g(甚至 -g3)编译 所有 代码。