Re: Release-mode only falure when comparing STL list::iterator-s




Ivan Vecerina skrev:

[snip]

Indeed, this seems to be a problem with a runtime-check infrastructure
shared by iterators of all containers of this STL implementation.

Quite a nuisance.
I will consider the suggested workaround:
#define _SECURE_SCL to 0
But for now the alternative fix I found will do: compare
the *addresses* of pointed-to elements instead of the
iterators, i.e. (a==b) --> (&*a==&*b)

This works only so long as both a and b point to data if one of these
equal end() you are technically dealing with undefined behavior. This
could give you real life problems only if the library should decide to
check for this. A real worry for debug builds.

/Peter

The most important for me is to know I have no undefined
behavior in my code. I was able to verify this in the
standard. (in the 1998 version of the standard that I
have, this statement appears under 23.1/10:
<< no swap() function invalidates any references, pointers,
or iterators referring to the elements of the containers
being swapped. >>

Thank you Tom for your excellent pointers,
Ivan

--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form

.



Relevant Pages

  • Re: Unified Ada library
    ... :> developers who think that the STL could only have been written in C++, ... Could you comment on the importance of iterators and generic ... we cannot present a standard interface to containers ...
    (comp.lang.ada)
  • Re: GCC 4.0 Ada.Containers Cursor danger.
    ... > Unordered containers do not exists. ... phase of the moon" which can't be the base for the standard. ... > hashed container) are delivered via iterators, ... > vary because the standard doesn't specify the hash table load factor.) ...
    (comp.lang.ada)
  • Re: Tuna fish
    ... It has been at least a year since I've purchased tuna. ... The cans have ... (i also only just recently noticed the rectangular plastic lidded containers ... standard package sizes, to be accompanied by howls of rage by the ...
    (rec.crafts.metalworking)
  • Re: Newbie question :) be kind...
    ... measuring system as a thing in itself, ... Consider the standard intermodal shipping containers. ... I liased with New Zealad Railways to move containers around the country. ... Most tunnels would clear the ...
    (rec.models.railroad)
  • Re: Identifying potions from memory
    ... The modern world comes with labels because the containers are all standardised and repeatedly purchased with the product. ... Same for potions, really. ... you'd find it even more likely that there might not be a standard labelling system. ...
    (rec.games.frp.dnd)