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: [email protected]
Reporter: [email protected]
CC: [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs