[llvm-bugs] [Bug 48136] New: alpha.unix.cstring.OutOfBounds wrongly triggers for flexible array members
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Nov 10 08:31:39 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48136
Bug ID: 48136
Summary: alpha.unix.cstring.OutOfBounds wrongly triggers for
flexible array members
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: dcoughlin at apple.com
Reporter: tss at iki.fi
CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org
We've been using alpha.unix checks, but OutOfBounds is annoyingly triggering
with flexible array members. Apparently it thinks they are 0 sized.
Using clang 12 from git, checked out Oct 27 2020.
# scan-build -enable-checker alpha.unix gcc test.c -o test
test.c:13:2: warning: Memory set function overflows the destination buffer
[alpha.unix.cstring.OutOfBounds]
memset(str->data, 'x', 10);
^~~~~~~~~~~~~~~~~~~~~~~~~~
When test.c contains:
#include <stdlib.h>
#include <string.h>
struct str {
size_t len;
char data[];
};
int main(void)
{
struct str *str = malloc(sizeof(str) + 10);
str->len = 10;
memset(str->data, 'x', 10);
return 0;
}
--
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/20201110/06ddbc25/attachment-0001.html>
More information about the llvm-bugs
mailing list