views:

115

answers:

1

I declare the following two function pointers in my class:

void (*ptrFunc)(void *);
bool (*ptrValid)(char *);

Now for some reason, the second pointer (ptrValid) causes the program to crash on exit. When I comment out the declaration the program exits fine, but when I un-comment it, it crashes.

Nothing is being assigned to it, it isn't being called, just declared.

Am I missing something here?

+6  A: 

What you describe doesn't make sense, that a declaration alone will cause your program to crash. But it might still be true if adding a variable to some class causes the memory usage of the program to differ in a way that causes the crash, if at some other, maybe unrelated, point you are accessing an invalid memory address or causing a memory overrun, etc. Maybe it is just unmasking a problem you had all along.

Try using a memory profiles like Valgrind or DUMA to figure out what's going on with your memory.

Gianni