Skip to content

regress: Don't provoke undefined behaviour

Simon McVittie requested to merge wip/smcv/issue458 into main

The 3 - 4 in this expression is evaluated before the left shift (as far as I understand it this is standardized, but unexpected, and clang-14 warns about it). The resulting left shift by a negative number is undefined behaviour (both gcc-13 and clang-14 warn about this, and produce arbitrary results; gcc's seems deterministic between program runs but clang's is not).

All that's needed here is a somewhat complicated expression, so change it to avoid UB.

Resolves: #458 (closed)

/cc @jbicha @pkgw @lkundrak

Merge request reports