|
Boost Users : |
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-05-06 15:47:04
AMDG
Torsten Sadowski wrote:
> 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?
>
This is not really a Boost question.
try using std::back_inserter(rnids) for the output.
In Christ,
Steven Watanabe
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net