Either an uninitialized pointer, or a pointer stored in memory that's been freed. I think cccccccc
is the first and cdcdcdcd
is the second, but it varies with compiler/library implementation.
For your particular code, probably myMap
hasn't been allocated yet, then myMap[0][0]
would result in an access attempt to 0xcccccccc
.
It can also happen that myMap
is the beginning of your class, and the class pointer was uninitialized:
class mMap
{
Tile myMap[10][20];
public:
void f() { myMap[0][0] = 0; }
};
mMap* what;
what->f(); // what is an invalid pointer
This happens because the member function is not virtual, so the compiler knows what code to run and passes the object pointer as a hidden parameter. Eventually the compiler emits a calculation like:
this + offsetof(Whatever::myMap) + z * sizeof(myMap[0]) + i * sizeof(myMap[0][0])
this
, being uninitialized, is 0xcccccccc
. Evidently the offsetof
part is zero, and i
and z
are both zero the first time through your loop, so you get 0xcccccccc + 0 + 0 + 0
as the memory address.
To debug this, use the call stack and find the function that called fillMap
. Then check in that function where the pointers used for member access (->
) came from.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…