DISQUS

DISQUS Hello! Elliott Back's Blog is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

Jump to original thread »
Author

C++ and the bad_alloc exception — Elliott C. Back

Started by elliottback · 8 months ago

No excerpt available. Jump to website »

1 comment

  • 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.

Add New Comment

Returning? Login