Just think of it this way:
Give this garbage pointer, how can you *possibly* know it's invalid? In C++, it just points to a memory location, and the runtime just assumes that you point to one that represents an object, or NULL.
Now, D3D *could* maintain a list of all known D3DWhatever pointers somewhere global, and check this every single time it's given a pointer. But that's costly, and it only helps very obscure cases like this one.
Valgrind might be able to detect this, if the memory being pointed to is uninitialized or something like that. But even then, it's kind of a gray area.
This is one very good reason why you should always initialized your pointers to NULL; it allows the runtime to detect when a pointer is definitely invalid.
Code Select
D3DWhatever* something = 0xFF00FF;Give this garbage pointer, how can you *possibly* know it's invalid? In C++, it just points to a memory location, and the runtime just assumes that you point to one that represents an object, or NULL.
Now, D3D *could* maintain a list of all known D3DWhatever pointers somewhere global, and check this every single time it's given a pointer. But that's costly, and it only helps very obscure cases like this one.
Valgrind might be able to detect this, if the memory being pointed to is uninitialized or something like that. But even then, it's kind of a gray area.
This is one very good reason why you should always initialized your pointers to NULL; it allows the runtime to detect when a pointer is definitely invalid.

