Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
What does "stored" mean?
• The nullptr value is stored in a pointer variable, just like any &someObject.
• There is no object of the correct “objective” form (if, of course, the object has some kind of invariant or at least a table of virtual methods) at the address *nullptr; on most operating systems, dereferencing nullptr results in a segmentation violation and an instant crash (but not necessarily - for example, DOS).
• In all ABIs I know of (x86/DOS, x86 and x64/Windows, x86 and x64/Linux), nullptr equals address zero. This is justified - this address is usually where the interrupt table, entry point, prefix segment or other system crap is located, you definitely shouldn't meddle here. But theoretically it is not necessary. This address, of course, is common for ABI, so that it is possible to combine the results of compilation in different languages into one program.
nullptr is just a keyword denoting a null pointer. Since it is empty, it is not stored anywhere.
Is it different in different programs... Is 0 different in different programs?
Come down here .
Hit something like
int* f()
{
return nullptr;
}
...ptr is a pointer. Pointer to what? If you read books, you would know what to address.
Therefore nullptr is different
nullptr is itself a constant (now its real value is not important). Where is stored, for example, 2 or 100500?
Here's when you make the assignment:
Then ptr will store nullptr.
If you look at the assembler code of such an assignment, then there will be something like:
In this example, I believe that the value of nullptr is 0. Here you can see that nullptr is stored directly in the code and is one of the operands of the mov assembly instruction.
About what is stored in memory, where nullptr points (and ptr from the example), wrote Mercury13
void *ptr = nullptr;
mov ax, 0;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question