Mike Miller 在 240. Uninitialized values and undefined behavior 中说:
The wording in 3.9.1 [basic.fundamental] was carefully crafted to allow use of unsigned char to access uninitialized data so that memcpy and such could be written in C++ without undefined behavior
这是什么意思?为什么要访问未初始化的数据?
最佳答案
当您复制包含填充的struct
时,memcpy
也会复制填充。通常,填充是未初始化的。
关于c++ - 未初始化的数据和 memcpy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13191277/