STL
STL copied to clipboard
`<concepts>`: `std::swap` for arrays uses `memcpy`
After #4991 std::swap for arrays uses memcpy. Normally these calls are optimized to inline vectorized operations that don't call anything external (and don't even use stack), but under certain conditions they can be actual memcpy calls.
This contradicts Core Headers intention.
Apparently, #pragma intrinsic(memcpy) forces the function call not to be inserted, even in /Od.
However there's no push/pop and no query of the state.
DevCom-10900610 may help resolving this.
When using Clang, it seems that we can use __builtin_memcpy_inline. Not sure whether it's a good idea to request MSVC to add the same intrinsic.
I would say that we're pretty confused about what "core headers" are supposed to be. Originally they were supposed to be free of runtime dependencies (e.g. the core of <type_traits> is compile-time-only and perfectly usable even in kernel mode, despite our general lack of support for exotic modes like that). Later we found it highly convenient to enforce the use of core headers only in the import lib, to keep things like basic_string out of it. But something like memcpy() is a middle ground - it's a runtime dependency, but not usually a problematic one.