DISQUS

DISQUS Hello!  The comments on this profile are unclaimed and thus are unverified.

Do they belong to you? Claim these comments.

Matthias Hofmann's picture

Unregistered

Feeds

aliases

  • Matthias Hofmann

Matthias Hofmann

3 years ago

in C++ and the bad_alloc exception — Elliott C. Back on Elliott Back's Blog
Quote: "Calling [] on a vector apparently returns *(begin() + offset), which when the offset is larger than the size points to invalid memory."

And that yields undefined behaviour, which means that anything can happen, including a bad_alloc exception being thrown. This is no way to "invoke that behaviour", and it does not contradict the standard either. It's simply a blunt mistake that should not happen, just like dereferencing a NULL pointer.
Returning? Login