Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

False positive reported by static analyzer: "Potential memory leak" #32666

Open Quuxplusone opened 7 years ago

Quuxplusone commented 7 years ago
Bugzilla Link PR33694
Status NEW
Importance P normal
Reported by Jeremy Friesner (jaf@meyersound.com)
Reported on 2017-07-05 13:27:30 -0700
Last modified on 2017-07-05 13:27:30 -0700
Version 2.7
Hardware Macintosh MacOS X
CC llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments bogus_memory_leak_warning.cpp (1693 bytes, text/x-csrc)
Blocks
Blocked by
See also
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
Quuxplusone commented 7 years ago

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