https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115160
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- Specifically, std::vector<uint8_t>::iterator::operator++(int) is "just a function", so the compiler doesn't "know" that it modifies the iterator every time it's called. To the compiler, the code looks like: (deref(inc(b)) | (deref(inc(b)) << 8) | (deref(inc(b)) << 16) | (deref(inc(b)) << 24) And this isn't clear that this modifies b and that the result depends on the unspecified order that each deref(inc(b)) subexpression is evaluated. But that doesn't really matter anyway. I don't think there is actually any undefined behaviour here at all, so UBsan should not give any errors. Evaluation of each *b++ subexpression happens before the evaluation of the next one. But the standard doesn't specify which one is "the next one". It's not undefined, but it's unspecified. So it's valid for the compiler to evaluate it left-to-right, but also valid to evaluate it right-to-left, or any other order as long as the b++ evaluations do not interleave.