GCC does not have a proper modulo overflow semantics for signed integral types. 1. The loop optimizer seems to assume that signed overflow does not happen (or is undefined). 2. On x86 INT_MAX/-1 seems to trap (instead of implementing modulo semantics).
In that case numeric_limits<signed>:is_modulo should be synchronized with gcc and be set to false instead of true. Another option, is to change gcc to fully support the modulo arithmetics of signed integer. -- Summary: numeric_limits<signed>::is_modulo is inconsistend with gcc Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: veksler at il dot ibm dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22200