My guess is that the code breaks strict aliasing in a way which is not catched by -Wall. IIRC strict aliasing warnings can yield false positives, so they are possibly disabled for warnings-as-errors.
You could try compiling with -fno-strict-aliasing but all other optimizations turned on, and seeing if it solves the problem (possibly after changing "unsigned short" to "uint16_t").
Of course, I don't mean that using a compiler flag is the fix (but making the code portable is).