On 3/13/22 00:04, Simon Josefsson wrote:
Reading the ideas in your responses, I think gnulib could help developers to use ASan/UBSan in their project by assisting with these choices. I'll see if I can come up with anything that is generally useful, once I get a couple of projects to build and self-test reliably with ASan/UBSan.
Something like --enable-gcc-warnings, but --enable-sanitizer? That would be helpful.
For what it's worth, I just now built GNU Emacs with 'clang -fsanitize=undefined' and it complained several times about adding 0 to a null pointer, due to code that's in Emacs not in Gnulib. I worked around the problem by compiling with '-fsanitize=undefined -fno-sanitize=pointer-overflow'. Of course this disables some useful checks.
It is a pain that Clang is wrongheadedly pedantic here. Adding 0 to a null pointer is well-defined in C++17, and there's no realistic possibility of Clang being ported to a platform where it's undefined behavior in C.
