C considered dangerous
C considered dangerous
Posted Aug 31, 2018 6:40 UTC (Fri) by iabervon (subscriber, #722)In reply to: C considered dangerous by epa
Parent article: C considered dangerous
It would probably be good enough to define memcpy_s() to write to only locations in the destination, and write values that are in the corresponding point in the source either before the operation or afterwards, independently for each location. If you don't realize the buffers overlap, and you intend to keep using the source buffer, memmove doesn't save you anyway. It's worth allowing memcpy_s to have the obvious performance optimization without also allowing the compiler to infer that the buffers don't overlap and start doing really unexpected things.
