My C++ Setup INFO : OS - Windows 10, IDE - VS Code, compiler - MinGw
ISSUE :
I recently found sanitizers for C++ to catch some runtime errors like out of bound array access with -fsanitize=address
and -fsanitize=undefined
in my VS Code environment.
This is a simple program for out of bound array access :
in VS Code terminal being used is CMD when i tried to compile the program with this line g++ -fsanitize=address check.cpp -o main.exe
On hitting enter I got this error ( cannot find -lasan ) :
here is the c++ code ->
// Program to demonstrate
// accessing array out of bounds
#include <iostream>
using namespace std ;
int main()
{
int arr[] = {1,2,3,4,5};
cout<<arr[0]<<endl;
// arr[10] is out of bound
cout<<arr[10]<<endl;
return 0;
}
Cause(s)/Solution(s) for this issue
How to fix cannot find -lasan ?
Does MinGW not support these sanitizers, if so, shall I use cygwin ?
Can I install clang on windows machine (if possible) to use this whole bunch of sanitizers ?
What are the other options to use besides using Visual Studio instead of VS Code ??
Any other suggestions
NOTE : kindly suggest me suitable tags for this post (if I have used a wrong one or missed a crucial one)