I ran into this issue on accident while debugging a faulty string trim function and now I'm wondering what exactly is causing this behavior.

Here's a code snippet with just the relevant bits:

```
#include <iostream>
#include <string>
using namespace std;

void debug(string s) { cout << "Len: " << s.length() << "; Value: '" << s << "'" << endl; }

int main()
{
    string str = "ABC";
    debug(str);

    str.erase( str.begin() + 4, str.end() );  // Magic!
    debug(str):

    return 0;
}

```

You'll notice that the erase function is taking an iterator that starts just beyond the end of the string. This isn't the exact input used when I ran into the issue (it was having a +1 which broke empty strings), but it has a similar effect. Here's the output:

```
Len: 3; Value: 'ABC'
Len: 4; Value: 'ABC '

```

When I change the `str.begin() + 4` to something greater like `+ 10` it becomes clear that I'm starting to pull in garbage data. 

My question is: how is it that using the erase() function ends up making the string *longer* than before? Also, is it just luck, or is the next character after the end of the string always whitespace?