GNU compiler memory sanitizer is not available

When I try to build my c++ project with memory sanitizer using the CMake sanitizers modules here, I get this warning:

MemorySanitizer is not available for GNU compiler.

Although when I searched on google it is stated here that GNU compiler supports memory sanitizer.

My development enviroment is WSL2 Ubuntu 20.04 and compiler version is 9.4.0.

>Solution :

As stated in the comments, the GCC documentation does not document support for MemorySanitizer. There is no entry for -fsanitize=memory– but it has -fsanitize=address, -fsanitize=leak, -fsanitize=thread and several others.

The High Performance Computing wiki page you linked in you question says:

The C/C++ compilers Clang/LLVM and GCC support so-called sanitizers. These sanitizers are built into the application code and track the execution at runtime to report execution errors. There are currently four interesting sanitizers:

  • AddressSanitizer and LeakSanitizer
  • ThreadSanitizer
  • MemorySanitizer

So it looks like it is speaking in broad strokes and that those broad strokes are wrong specifically for GCC and MemorySantizer.

Cross reference: Google wiki page on MSan:

MemorySanitizer is part of LLVM trunk and has been widely available as a compile-time option in clang since version 4.0.

Page for Clang support:

For your reference, the line of CMake code in the CMake helper modules you are using that prints that diagnostic message is here:

Leave a Reply