I have been encountering some strange behaviour in ghc, but it now seems to be fixed thanks to Chris Ryder. Apparently, the latest GHC likes to use GCC 3.3, and I was using gcc 4.0.
Bizzarre - but it works. I thought it could be because I had bad RAM but after running an exhaustive test that took about 6 hours (ran all night) it passed.