-
Notifications
You must be signed in to change notification settings - Fork 18
Description
blink_copy uses memcpy which executes undefined behavior for overlapping memories [1] [2]. We do indeed have overlapping memories (in at least CCA). The tests pass on Windows, but that's not guaranteed to happen. The CCA test definitely fails on Linux. For now, I've added a commit (7e27886) to allow Linux to use memmove instead of memcpy. Historically, memmove has been slower than memcpy, and it probably still is, but both have a time complexity of O(N) so I would suggest using memmove for the Windows implementation as well. Alternatively the compiler could figure out when to use memmove instead of memcpy. And worst case scenario, we could just rely on undefined behavior in Windows.
[1] - https://msdn.microsoft.com/en-us/library/dswaw1wk.aspx
[2] - http://man7.org/linux/man-pages/man3/memcpy.3.html