Fix cmake build issues and gcc hang
There were both compiler and linker errors using CMake on both Linux and OSX. This changeset fixes them. Compiles, builds, and tests successfully on OSX (cmake and Xcode). Compiles and builds on Linux.
I also found the problem that was causing #44. All tests pass in release mode on Linux. All these changesets build and test on OSX, but I do get some test failures that I get without this changeset as well.
Hangs and segfaults can happen all over the place (depending on compiler version and optimization options) because old C tricks in list.h break the assumptions made by modern compilers. So, although basically on the right track, the third commit only fixes one of many symptoms of an underlying problem addressed by #104.
@tschw After one of my most epic debugging adventures in many years, I was just orbiting the solution. That change makes so much sense, thank you for it. I will test it out this week.
Hahaha! Although the patch reads so nice and simple, I too had some fun debugging: When it comes to optimized executables, you have no choice but to strainfully trace the program at assembly level. In my case, the crash actually happened in the second iteration of a loop - one I could step through four times at source level.