https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66828
--- Comment #2 from Thomas Preud'homme <thopre01 at gcc dot gnu.org> --- The C standard says nothing about the cumulative effect of several shift so I'm guessing that the real issue is probably that the type is signed. Quoting C99 section 6.5.8 paragraph 4: "If E1 has a signed type and nonnegative value, and E1 × 2E2 is representable in the result type, then that is the resulting value; otherwise, the behavior is undefined." Which is the case for the last iteration.