Re: strange crash after assertion with std::map::iterator
"Duane Hebert" <spoo@flarn2.com> wrote in message
news:eu0IVEVgHHA.4416@TK2MSFTNGP03.phx.gbl
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:u1xYQ4DgHHA.1552@TK2MSFTNGP06.phx.gbl...
Mycroft Holmes <m.holmes@nospam.it> wrote:
the standard is very clear, but bizarre: I'd expect that
default-constructed iterators should behave as default-constructed
pointers (i.e. null)
What makes you think default-constructed pointer is NULL? Consider:
int* p;
assert(p == NULL); // will likely fail
Absolutely but I would have expected his original
example to just set t to false. Why assert?
Both the original example involving iterators, and my example above
involving pointers, exhibit undefined behavior. Modern STL
implementations help you diagnose some undefined behavior when using
STL, just like many Lint-like tools would help you diagnose some
undefined behavior caused by misuse of pointers.
And why
assert with iterator debugging disabled?
Nothing in the OP's message suggests that he or she has disabled
iterator debugging. In any case, I woudldn't be surprised if this check
is performed in debug build regardless of whether iterator debugging is
disabled or not. Why do you feel it matters?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925