http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50865
--- Comment #7 from Jaak Ristioja <jaak at ristioja dot ee> 2011-10-25 16:08:19 UTC --- (In reply to comment #6) > /* X % -Y is the same as X % Y. */ > (fold-const.c:fold_binary_loc) would probably be what's wrong here. On the other hand https://www.securecoding.cert.org/confluence/display/seccode/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow#INT32-C.Ensurethatoperationsonsignedintegersdonotresultinoverflow-Modulo also refers to C99, saying that X % Y and X % -Y are equivalent.