Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
val = -val will cause overflow when val = LLONG_MIN, and the result is undefined. So the compiler could assume val != LLONG_MIN, and val will always be positive after this: if (val < 0) { val = -val; } So the later check if (n < 0) is ignored. gcc -O2 uses this assumption, while gcc -O1 or clang doesn't. Special case LLONG_MIN to avoid this overflow.
- Loading branch information