Based on corrections of annotations to the standard.
3.14 An object is either a variable or a constant that resides at a physical memory address.
- In C, a constant does not reside in memory, (except for some string literals) and so is not an object.
It makes sense to me that a const will not have an actual memory location (except possibly for string literals) and that it depends on the compiler, which will most likely replace all references to it with the literal value. That being said, how is the following possible?
const int * foo;
This declares a pointer to a const int
. However, constants don't have an address, so what does this really mean? You can't have a pointer to a literal value that only exists at compile time.