This is my code
#include <stdio.h>
#include <stdlib.h>
int main()
{
int *m = malloc(3 * sizeof(int));
m[0] = 1;
m[1] = 2;
m[5] = 3;
}
I want to be able to detect the memory leaks (as I am using malloc
without using free
. I was able to use clang test.c -o test -fsanitize=address -g
but I am unable to use -fsanitize=memory
or -fsanitize=leak
. As I am getting the following error: clang: error: unsupported option '-fsanitize=memory' for target 'arm64-apple-darwin21.2.0'
and clang: error: unsupported option '-fsanitize=leak' for target 'arm64-apple-darwin21.2.0'
. I just wanted to know exactly what I have to do in order to use Memory Sanitizer and Leak Sanitizer on my macOS Monterey and be able to check that I just accessed memory that I should not have.