-1

I use addresses within a list to ensure quick access to my instances. In the constructor I initialize each address with NULL. However, when querying before anyone sets the address (unless the constructor sets it to NULL), either 0x0000000000000000 or 0xdddddddddddddddddd is now in the pointer.

Where does the 0xdddddddddddddddd come from? I have in In Visual Studio C++, what are the memory allocation representations? found the following:

  • 0xDDDDDDDD: Used by Microsoft's C ++ debugging heap to mark freed heap memory

but I don't understand that, I set the pointer all to NULL?

Alan Birtles
  • 32,622
  • 4
  • 31
  • 60
Metatron
  • 165
  • 1
  • 8
  • 1
    The issue is with your code. No one can answers that without code. In debug mode 0xDD is dead memory, i.e. "Memory that has been released with delete or free. It is used to detect writing through dangling pointers". It'll be set when you call delete or free. See [When and why will a compiler initialise memory to 0xCD, 0xDD, etc. on malloc/free/new/delete?](https://stackoverflow.com/q/370195/995714) – phuclv Apr 20 '20 at 06:32
  • 4
    please show a [mre] – Alan Birtles Apr 20 '20 at 06:32

1 Answers1

0

You are probably in debug mode. All variables that are not initialized properly are initialized to some easily recognizable value that will hopefully lead to an immediate crash when used.

You need to explicitly initialize your raw pointer to null.

CygnusX1
  • 20,968
  • 5
  • 65
  • 109
  • 3
    Probably not the cause, uninitialised memory is filled with either `CC` or `CD` depending on whether it's heap or stack. `DD` indicates deleted memory – Alan Birtles Apr 20 '20 at 06:51