top | item 37377438

(no title)

au8er | 2 years ago

Would it be better to do

  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

discuss

order

ynik|2 years ago

At least in clang, your variant is not any better: uninitialized reads return the special value `undef`, which the compiler can constant-propagate to both uses of `sparse_val`. But then each `undef` can turn to a different value at each use, even if they both came from the same uninitialized read.