Attempted to reproduce segfault in C++