by lmm · 3y ago · 0 comments
is-member(i):
return sparse[i] < n && dense[sparse[i]] == i
there's no requirement for the two sparse[i] to take the same value (since that expression evaluates to an indeterminate vaule). So the second occurrence of sparse[i] can take a value >=n, or indeed greater than the length of the whole array, at which point reading it is definitely UB. sparse_val = sparse[i]
return sparse_val < n && dense[sparse_val] == i
Regardless, we are treading in undefined territory, and the behaviour is not something that can be reliably be dependent upon