PDA

View Full Version : What is the displayed "value" of a pointer in the debugger?



feraudyh
3rd September 2014, 20:23
Hi,
I'm using QtCreator to debug a program. I have an issue with the display of pointers when using QtCreator to debug a program.
I simplified my program to this:

#include <QCoreApplication>
#include <stdio.h>

int main(int argc, char *argv[])
{
QCoreApp a(argc, argv);

int **parray = new int *[5];
printf("parray is %p\n",parray);
for(int i = 0; i < 5; i++)
parray[i] = new int[5];

return a.exec();
}

Now if I put a breakpoint on the line return
a.exec();
the debugger reports parray as having value 0 in the pane where it reports the value of all local variables.
This looks strange as the printf indicates the pointer is not null (as you would expect).

My allocation looks ok, so what is the 0 referring to?

feraudyh
4th September 2014, 05:47
In fact the problem appears with just this:

int *p = new int[5];
// the value of p is displayed as zero
The problem arises in my Linux version of QtCreator, but not in MinGw (under windows).
I wonder if this is not a bug.