Opened 17 months ago
Last modified 17 months ago
#87 accepted defect
Struct self-assignment results in assertion failure in memcpy
Reported by: | Lukáš Zaoral | Owned by: | mornfall |
---|---|---|---|
Priority: | major | Milestone: | 4.3 |
Component: | DiOS | Keywords: | |
Cc: | kdudka@…, jamartis@…, lzaoral@… |
Description
Hi,
the following code makes Divine 4.3.6 crash with an assertion failure in the DiOS's implementation of memcpy
. While it is true, that the memory passed to memcpy
should not overlap, the struct
self-assignment should be permitted.
Thanks.
int main(void) { struct { char a; int i; } s; s = s; }
Note: See
TracTickets for help on using
tickets.
That's interesting, because this looks like the code generated by clang/llvm is wrong. I will investigate, but clang usually emits an intrinsic version of 'memcpy' which on many/most architectures is replaced with specialized native code directly by the codegen. But the llvm-builtin fallback is to call 'memcpy' (we do no such replacement in our code as far as I can tell).