3 ms·
I don't think he is correct. The underlying representation of a pointer is not defined by the C standard. You could have a C implementation that works on segmen
by icedchai 8y ago
I don't think he is correct. The underlying representation of a pointer is not defined by the C standard. You could have a C implementation that works on segmented, non-flat architectures. Look at the C compilers from the DOS days, for example...
- steveklabnik 8y agoI think we're talking past each other, and in some ways, this is what the post is about. The C abstract machine presents a flat, uniform, byte-addressed address space.[1] The reason that it does not define what a pointer's representation is is because it needs to map that to what the hardware actually does, which is your point. 1: Actually, my impression is that it does, but this is actually an area of the spec in which I'm less sure. I'm going to do some digging. Regardless, the point is that the memory model != the machine model, which is your point. EDIT: For example, https://en.cppreference.com/w/c/language/memory_model https://en.cppreference.com/w/c/language/memory_model > The data storage (memory) available to a C program is one or more contiguous sequences of bytes. Each byte in memory has a unique address. Though cppreference is not the spec itself, of course. It is the conceptual model that's often presented. LAST EDIT: I happened to run into someone who seemed knowledgeable on this topic on Reddit: https://www.reddit.com/r/programming/comments/9kruju/should_you_learn_c_to_learn_how_the_computer_works/e71l1zg/ https://www.reddit.com/r/programming/comments/9kruju/should_... TL;DR no! This is another misconception. Tricky!
- icedchai 8y agoYep, these common assumptions are not always true if you read deep enough into the spec. Even though they may be true in practice, only as a side effect in most implementations... I taught myself C when I was a teenager (on an Amiga, back in the 80's.) It is amazing that almost 30 years later, I'm still learning new things about it.