Re:Clang emits memcpy for std::swap, which can introduce und...
by chandlerc1024 on Sunday April 24, 2016 @08:18PM
(#11561935)
The compiler is not producing C code that calls memcpy. It is leveraging a specific implementation of a memcpy symbol in a particular system library. The contract between Clang and that system library can include guarantees not provided by any ISO standard.
Re:Clang emits memcpy for std::swap, which can introduce und...
by Dylan16807 on Sunday April 24, 2016 @08:40PM
(#11561979)
Then the bug report is wrong, and disregard the second and third posts I made. They depend on the bug report not being wrong.
My first post is generic and not about this particular issue; it's still fine.
Re:Clang emits memcpy for std::swap, which can introduce und...
by whitequark_ on Sunday April 24, 2016 @09:06PM
(#11562059)
The bug report is not wrong. Rather, whether the current behavior is correct depends on the platform.
For example, Darwin's libc offers this contract for memcpy and clang is perfectly within its rights to generate such code (note that the IR it generates is still violating LLVM's contract on the memcpy intrinsic); glibc offers no such contract for memcpy, and so clang's code is nonconformant.
And even that is only if the bug report is correct.