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: kreme...@apple.com
          Reporter: war...@icouldbedeadwrong.net
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to