Program crashes when built with Clang but runs when built with GCC