Created attachment 18754
Self-contained example program that reproduces the false-positive when you
compile it using scan-build
Hi all,
When I run the attached trivial example program through clang's scan-build
utility, I get a warning message that I believe is a false positive:
$ scan-build g++ bogus_memory_leak_warning.cpp
scan-build: Using '/Users/jaf/checker-279/bin/clang' for static analysis
bogus_memory_leak_warning.cpp:26:4: warning: Potential memory leak
}
^
1 warning generated.
scan-build: 1 bug found.
scan-build: Run 'scan-view
/var/folders/1x/wkkcw0xx6dl54r2326vk0lh80000gn/T/scan-build-2017-07-05-132302-
32588-1' to examine bug reports.
AFAICT the code in the trivial example program doesn't have any actual memory
leaks, but SA thinks that it does. (If I'm wrong about that, I apologize).
Also note that if I comment out line 25 in the attached file, the false-
positive warning goes away; however I think the presence of that line should
not make any difference regarding whether the program has a memory leak or not.
(This example application is just a minimal self-contained example, of course;
the actual codebase where I see this sort of false positive pop up is much
larger, but this example is easier to understand and debug)
-Jeremy
Attached bogus_memory_leak_warning.cpp (1693 bytes, text/x-csrc): Self-contained example program that reproduces the false-positive when you compile it using scan-build
bogus_memory_leak_warning.cpp
(1693 bytes, text/x-csrc)