Skip to content

Instantly share code, notes, and snippets.

@niya3
Last active July 20, 2018 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niya3/43fc19709df1065482a12f79a391cffe to your computer and use it in GitHub Desktop.
Save niya3/43fc19709df1065482a12f79a391cffe to your computer and use it in GitHub Desktop.
simple ASAN expample
#include <iostream>
int f(){
const int M = 55500;
//int N = M + 3;
int N = M - 1;
int *a = new int[M];
a[N] = 14;
return a[N];
}
int g(){
return f();
}
int main(){
std::cout << g() << std::endl;
return 0;
}
.PHONY: main
main: m.cpp
g++ -g -o $@ $^ -fsanitize=address
$@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment