Opened 12 months ago

Last modified 11 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@…


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.


int main(void)
    struct {
        char a;
        int  i;
    } s;
    s = s;

Change History (1)

comment:1 Changed 11 months ago by mornfall

Owner: set to mornfall
Status: newaccepted

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).

Note: See TracTickets for help on using tickets.