Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How would you define what a memory address is without first defining in which context it has a meaning?


C was written as a portable assembly language, so I think a memory address is a number that CPU considers to be a memory address.


That’s currently the case in C, in that you can convert pointers to and from uintptr_t. However, not every number representable in that type needs to be valid memory (that’s true on the assembly level as well), hence it’s only defined for valid pointers.


> I think a memory address is a number that CPU considers to be a memory address

I meant to say that, indeed, there must be some concept of CPU for a memory address to have a meaning, and for this concept of CPU to be as widely applicable as possible, surely defining it as abstract as possible is the way to go. Ergo, the idea of a C abstract machine.

Anyway, other people in this thread are discussing the matter more accurately and in more details than I could hope to do, so I'll leave it like that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: