Comment by pinoy420

Comment by pinoy420 5 months ago

3 replies

Amazing it can do that. How does it work?

That definitely does seem to change its semantics to me. I am not a c expert but this surely has problems the previous one doesn’t?

hathawsh 5 months ago

It does change the semantics if n is negative or large enough to cause an overflow. The challenge for the compiler is to somehow prove that neither of those things can happen.

  • kryptiskt 5 months ago

    It doesn't have to prove absence of overflow since that is undefined behavior in C and thus modern compilers assume it can never happen.