clang analyzer memory leaks

2019-08-04 12:51发布

问题:

Why doesn't clang/clang-analyzer catch that I forgot to free a and have a memory leak? It's obvious. I looked at the man pages and i'm not sure what flags are required.

$ scan-build clang++ -std=c++11 a.cpp
scan-build: Using '/usr/bin/clang' for static analysis
scan-build: Removing directory '/tmp/scan-build-2013-10-02-2' because it contains no reports.
$ cat ./a.cpp

#include <iostream>

int main() {
        int *a = new int;
        *a = 8;
        std::cout<< a << std::endl;
}