From: Beman Dawes (bdawes_at_[hidden])
Date: 2004-02-22 21:50:34
At 06:12 AM 2/22/2004, Bronek Kozicki wrote:
>Bronek Kozicki <brok_at_[hidden]> wrote:
>> I suppose there might be some problem with vc71 static runtime
>> library, but maybe you have other explanation?
>OK, I know the reason. Sorry for bothering you. We have unusual
>manifestation of undefined behaviour here - tokenizer should not be
>initialized with temporary string. It does not make a copy of its
>string argument, instead it stores only begin and end iterators. Of
>course these iterators are no longer valid once temporary string
>variable is destroyed. Program could crash, but it can do anything else
>when dereferencing such dangling iterator.
Ouch! That seems an unfortunate design decision. Perhaps two forms of
constructors could have been provided - one form that takes two iterators
and doesn't store a copy of the contents, and another form like the current
constructors which takes a container reference but (unlike the current
constructor) makes a copy. I wonder if that was discussed at the time? Or
is there a better way to prevent the problem?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk