fix builds with gcc 4.6.3

disable spurious warnings (unused-but-set-variable, unused-variable) and
fix accurate ones (sign-compare)