I have the following code :-
void someFunc (someStruct* obj) {
cout << obj->some_member;
}
someFunc is a call-back that I get from a library that I have no control over. If I compile this with gdbon=true then the resulting exec works exactly as it is supposed to do. On the other hand, if I compile it without the above flag, the exec segfaults. Opening up the core-dump in gdb shows that
obj=Variable "obj" is not available.
Any ideas on how I can narrow down the problem further (or what might possibly be wrong)?
EDIT:- Hey turns out this was a non-issue. There was an unsafe memory access much later in the code which in the release build (what with optimisations and all) appeared to gdb to be a problem in the above line of code. What's really surprising is that I tried to do this :-
void someFunc (someStruct* obj) {
if (obj==NULL) return;
cout<<"here1\n";
cout<<obj->some_member;
cout<<"here2\n"
}
And this would randomly result in
here1
sometimes and
here1
here2
some other times. Which kinda confused me a bit again... But the problem was elsewhere...