Adapt a patch from around the internet to fix an issue with gcc 4.6.