From Loius Brandy’s CppCon 2017 talk.
Asan has a ‘use after scope’ option which is not enabled by default (until recently). Turn it on with -fsanitize-address-use-after-scope
.
Catches bugs like this one:
volatile int *p = 0;
int main() {
{
int x = 0;
p = &x;
}
*p = 5;
return 0;
}