Hello,
I have program like this:
Code:
vector<A *>::iterator it;
for ( it=vec.begin() ; it != vec.end(); it++ )
cout << *it << " ";
cout << endl;
sort(vec.begin(), vec.end(), CompF);
with 'gcc -g' it runs well, but with 'gcc -g -O3' (with -O2 too) it crash.
output is something like this:
Code:
0x826fff8 0x8270440 0x82720b8 0x8273d40 0x82796b8 0x8279808 0x82799b0
and gdb says
Code:
in CompF (a=0x8273d40, b=0x209) at file.cpp:123
Why it try to compare something at address 0x209 when this address is not in the vector?