Andrzej Krzemienski wrote:
5. Compiling with -Wall gives me a warning in GCC when sorting an empty hub: a zero-sized heap array is allocated: https://godbolt.org/z/dWvxv9n8s This is technically fine to allocate such arrays, but maybe it is worth to make -Wall clean.
The warning isn't caused by the zero sized allocation (which is legal.) It's because the compiler can see that the array has zero elements, but can't see that the loop inside this call to visit https://github.com/joaquintides/hub/blob/063cf1d3589d4893b53964084ee56f4476e... is never executed. So it says "if this loop is executed, it would be UB because there aren't any elements there" but this is a false positive because the loop isn't executed. (The subsequent loops suffer from the same issue and also cause warnings for the same reason.) A common problem with GCC, and unfortunately nothing can be done about it short of disabling the warning.