I'm trying to get clang++ to tell me there is a memory leak. I tried scan-build but it reported nothing. How do I get llvm/clang to warn me of this problem?
#include <iostream>
int main() {
int *a = new int;
*a = 8;
std::cout<< a << std::endl;
}
False-positive pruning usually leads to removing all leaks that originate from main(), since the program will exit anyway. Try analyzing the same code, but in a different function.
Because int is too small, there is something like one "reserved section" for program so for small object no need to extend memory area, try to apply 1024 * 1024 * 10 then check the result