Pete Becker
10/30/2008 12:31:00 PM
On 2008-10-30 08:22:14 -0400, Richard Herring <junk@[127.0.0.1]> said:
> In message <2008103007325843658-pete@versatilecodingcom>, Pete Becker
> <pete@versatilecoding.com> writes
>> On 2008-10-30 07:20:58 -0400, "Moschops" <moschops@notvalid.com> said:
>>
>>> In moving some code from VS6 to VS2008 (bear with me, this is not a VS
>>> question, I'm just setting context), we find new crashes that weren't there
>>> before and we think they're related to trying an operation on a multimap
>>> that is empty - for example,
>>> std::multimap<double, aStructWeHaveDefined>::iterator low;
>>> low = c.begin() ; // c is empty (i.e. c.empty()==1) but we haven't
>>> checked for it
>>> In VS6 these crashed did not occur, in VS2008 they do. Can anyone tell me
>>> what is supposed to happen?
>>
>> The behavior is undefined.
>
> ???
>
> Surely the result of calling begin() on an empty multimap (or any other
> std:: container, for that matter) is an iterator which compares equal
> to that returned by end().
Whoops, I read it as c.first(). You're absolutely right: c.begin() is
well defined.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)