[LLVMbugs] [Bug 23893] New: False positive (divide by zero), involving ALIGNOF()
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jun 19 02:47:53 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23893
Bug ID: 23893
Summary: False positive (divide by zero), involving ALIGNOF()
Product: clang
Version: 3.4
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: kremenek at apple.com
Reporter: arnsholt at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
In the MoarVM project, we have some code that looks like this (computing
offsets for struct members):
size_t cur_size;
size_t align = ALIGNOF(void *);
/* Stuff we don't care about here, setting cur_size */
if (cur_size % align)
cur_size += align - cur_size % align;
The static analyzer thinks that `align` is initialized to 0 and thus that
there's a potential divide-by-zero in the modulo operation. This is clearly not
possible, since the smallest possible ALIGNOF value is 1.
Our ALIGNOF is implemented like this:
#define ALIGNOF(t) ((char *)(&((struct { char c; t _h; } *)0)->_h) - (char
*)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/20150619/ab2548b6/attachment.html>
More information about the llvm-bugs
mailing list