Boost logo

Boost Users :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2006-12-18 11:07:12


On Dec 17, 2006, at 3:07 AM, Silvia Richter wrote:

>
> Douglas Gregor wrote:
>> On Thu, 2006-12-14 at 04:52 +0000, Silvia Richter wrote:
>>
>>> I call adjacent_vertices() on a vertex A, which gives me an
>>> adjacency_iterator. Then I remove all edges from A by calling
>>> clear_vertex().
>>> Then I want to use the adjacency_iterator obtained previously to
>>> check the new
>>> degrees of all (previous) neighbours of the removed vertex v. But
>>> the program
>>> crashes with a segmentation fault, when I try to use the iterator.
>>>
>>
>> Unfortunately, this won't work. Once you've called clear_vertex(),
>> the
>> data that the adjacency_iterator for that vertex relies on has been
>> removed.
>>
>>
>
> Thanks for that. I have in the meantime posted another comment (you
> may
> have seen it), when I experienced that my code works with certain
> older
> compilers, but not with newer ones. Looks like that is just
> coincidence,
> then (?)

I believe that is just a coincidence. Once the call to clear_vertex()
has been made, any use of adjacency_iterator for that vertex is
"undefined behavior", which means that it might work on might fail...
we just won't know.

        Cheers,
        Doug


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