Reported by Nathan and fixed by his patch. I added the tests. Tested powerpc64le-linux, committed to trunk. This should be backported too.