#0 strlen () at ../sysdeps/x86_64/strlen.S:106
#1 0x00007ffff7b64229 in std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x0000000000400c9b in main () at main.cpp:19
Your problem isn't the insanely large string -- that's just a matter of having enough memory on your computer.
Your problem is you're trying to return a pointer to an object that no longer exists. std::string output (see [1]) is a local variable, and is deallocated once your test function ends. I'm disappointed g++ doesn't warn about this even with all warnings on.
Just use std::strings if you're not sure what's going on.