The Word is not the Thing.
All x
, and p
, and for that matter p.type1
are is names, or identifiers. So, I guess you're really asking what they identify. The answer is that they identify something, which behaves as if it fulfills certain requirements made by the language specification. What this identified thing actually is will depend on your platform, compiler, maybe what optimizations you have turned on, etc. etc.
So, let's take the statement
int x = 6;
You're saying that x
is now (in this scope and possibly nested scopes) going to refer to an int
(whatever that is), and giving it the initial integer literal value 6
.
So, what is an int
? It's a thing which can hold a single (positive or negative) integer value, within the range [std::numeric_limits<int>::min(),std::numeric_limits<int>::max()]
. Its exact size is architecture-dependent, but it's at least as big as a char
and no larger than a long
(IIRC).
Likely candidates for what this thing could be:
- sufficient memory to hold whatever an
int
is on your platform, associated with a linker symbol (possibly relocated at runtime) if it's a global declaration, so all the code referring to x
uses the same memory location
- sufficient memory at a fixed offset from the stack (or stack-frame) pointer register if it's a function-scope local variable: the compiler is responsible for tracking the variables it's going to put here inside each function, and remembering which offset is associated with each identifier. This is a common default (unoptimized) case
- a register, of sufficient size to store an
int
: if you never take the address of x
it may be able to spend its whole life inside a register, but if you either take the address or the compiler runs out of registers for all your variables (or needs to save them across a function call), x
may be loaded into a register when you're working with it, and spilled back to stack. Again, it's up to the compiler to remember when x
is currently a register (and which one), and when it's a memory location
As you can see, the "thing" x
identifies can really be lots of things, at different points during the execution of your program.
Unless you're optimizing something or carefully laying out your memory, a more useful question is what are the properties of x?
The point of the standard (or any language spec, really) is to make some useful guarantees about types, variables and behaviours, and then let the compiler choose how to achieve those guarantees.