~sergio-br2/gme/trunk

Viewing all changes in revision 42.

  • Committer: michael.pyne
  • Date: 2013-06-09 22:36:07 UTC
  • Revision ID: git-v1:9dd4d7687b5ba4f16afd86da435df1b5460f9f60
Fix undefined left-shift of signed int.

Detected by PVS Studio [1], left shift of a signed integer that causes the sign
bit to "fall off" is technically undefined behavior (though neither clang nor gcc seem
to warn for this case).

Could also be fixed by using an unsigned bitmask, doing the shifts, and
reinterpreting as an int when doing the comparison to 0, but that seems more
trouble than it's worth.

I've tested by playing a bunch of SPC files, haven't heard any problems.

[1] http://www.viva64.com/en/examples-V610/

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: