[llvm-bugs] [Bug 25701] New: False positive: memory leak reported for cast to union

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 1 18:12:48 PST 2015


https://llvm.org/bugs/show_bug.cgi?id=25701

            Bug ID: 25701
           Summary: False positive: memory leak reported for cast to union
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: warren at icouldbedeadwrong.net
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 15378
  --> https://llvm.org/bugs/attachment.cgi?id=15378&action=edit
Test case

Platform: Ubuntu 14.04.2 LTS
Tool version (svn info):
   URL: http://llvm.org/svn/llvm-project/cfe/trunk/tools/scan-build
   Relative URL: ^/cfe/trunk/tools/scan-build
   Repository Root: http://llvm.org/svn/llvm-project
   Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8
   Revision: 254388

I have written a small test case (see attachment) - this code compiles and
passes through valgrind without issue.  However, scan-build complains about a
possible memory leak, as follows:
/opt/llvm/libexec/ccc-analyzer -o union -g -Wall -Wextra union.c
union.c:25:5: warning: Potential leak of memory pointed to by 'ret'
    return (request_un)ret;
    ^~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

(Note that the memory in question is freed on line 42).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151202/d8a792b8/attachment-0001.html>


More information about the llvm-bugs mailing list