6 May
2008
6 May
'08
11:35 a.m.
Hi, I have a bug when using set_difference with lists which puzzles me. The code runs like this: list<int> nids,gnids,rnids; //fill nids and gnids nids.sort(); gnids.sort(); set_difference(nids.begin(), nids.end(), gnids.begin(), gnids.end(), rnids.begin()); It works as expected in debug mode (-O0) but crashes in optimized mode (-O3). rnids is still empty after set_difference and the program crashes as soon as I try to use rnids. If I use a vector of the right size for rnids everything works. Obviously the memory allocation for the receiving list is optimized away. Is this not against the idea of the STL algorithms? Cheers, Torsten