Skip to content

Removed an unecessary condition that GCC optimizes out and produces a warning blocking compilation.

Matthieu Schaller requested to merge Sorting_fix into master

GCC 5.x.y returns a lethal warning when compiling the code:

space.c: In function 'parts_sort': space.c:595:12: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow] if (jj + 1 < j && pivot + 1 < max) { ^ space.c: In function 'gparts_sort': space.c:735:12: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow] if (jj + 1 < j && pivot + 1 < max) {

After some research it turns out that the compiler notices that the condition "jj + 1<j" is always true and attempts to optimize it out. But it is only true if j and jj don't overflow (which is what we want anyway). So since it is an "unsafe" optimisation, the compiler returns a warning and we die on warnings...

In this patch I completely remove that condition. Do you agree with that fix ?

Note that the parallel_sort branch suffers from the same issue.

Merge request reports