The Issue:
Stroustrup's claim that modern hardware cannot store objects smaller than a word clashes with the reality of modern processors, like x86, which routinely handle byte-sized storage and retrieval.
Stroustrup's Intended Meaning:
It's possible that Stroustrup was referring to a hypothetical ISA without a well-defined memory model, where byte storage could potentially overwrite neighboring bytes during a processor cycle.
Modern Hardware Implementation:
However, this is not the case with modern ISAs. Byte-store instructions are atomic and do not disturb surrounding bytes, whether implemented using:
Exceptions and Considerations:
While modern CPUs prioritize byte-sized storage efficiency, there may be some nuances to consider:
Implications for C :
Stroustrup's quote highlights the importance of:
Conclusion:
Modern x86 hardware and many other modern ISAs provide efficient and reliable byte storage, disproving Stroustrup's claim. However, it remains crucial for programmers and compiler designers to understand the implications of memory models to ensure data integrity and thread safety.
The above is the detailed content of Can Modern Hardware Really Store Bytes Without Affecting Neighboring Bytes?. For more information, please follow other related articles on the PHP Chinese website!