[llvm-bugs] [Bug 39884] New: Analyzer fails to recognize C-style union struct initialization
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Dec 4 17:28:11 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=39884
Bug ID: 39884
Summary: Analyzer fails to recognize C-style union struct
initialization
Product: clang
Version: 7.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: dcoughlin at apple.com
Reporter: renat at idrisov.info
CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org
Hi All,
I run analysis on a piece of code with:
$ clang-tidy tidy-minimal.c -checks=* --
Code:
#include <stdio.h>
#include <stdlib.h>
struct a {
union {
struct {
void *b;
};
};
};
void *something();
void something_else(struct a *param);
void myfunction() {
struct a c = { .b = malloc(256) };
something_else(&c);
}
int main() {
myfunction();
}
----------------
I get:
/.../tidy-minimal.c:18:1: warning: Potential memory leak
[clang-analyzer-unix.Malloc]
}
^
/.../tidy-minimal.c:21:3: note: Calling 'myfunction'
myfunction();
^
/.../tidy-minimal.c:16:23: note: Memory is allocated
struct a c = { .b = malloc(256) };
^
/.../tidy-minimal.c:18:1: note: Potential memory leak
}
^
----------------
It looks like it is not handling struct initialization properly because if I
remove union -- it produces no warnings
The issue could be related to https://bugs.llvm.org/show_bug.cgi?id=35882
but in my case giving union a name does not resolve it.
Thanks!
--
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/20181205/6a2d0137/attachment.html>
More information about the llvm-bugs
mailing list