TensorUInt128 division infinite loop
<!-- Thank you for submitting an issue! Before opening a new issue, please search for keywords in the existing [list of issues](https://gitlab.com/libeigen/eigen/-/issues?state=opened) to verify it isn't a duplicate. --> ### Summary <!-- Summarize the bug encountered concisely. --> The TensorUInt128 division algorithm attempts to find `n` such that `lhs <= 2^n * rhs` by doubling `rhs`. This algorithm can get stuck in an infinite loop [here](https://gitlab.com/libeigen/eigen/-/blob/master/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h#L204): ```cpp TensorUInt128<uint64_t, uint64_t> power2(1); TensorUInt128<uint64_t, uint64_t> d(rhs); TensorUInt128<uint64_t, uint64_t> tmp(lhs - d); while (lhs >= d) { tmp = tmp - d; d = d + d; power2 = power2 + power2; } ``` If `d` overflows, the loop continues forever. This happens whenever whenever `lhs > 2^127`, as there is no multiple of `rhs` that can meet this condition. For example: ```cpp Eigen::internal::TensorUInt128<uint64_t, uint64_t> a(1ULL << 63, 1); Eigen::internal::TensorUInt128<uint64_t, uint64_t> d(2); Eigen::internal::TensorUInt128<uint64_t, uint64_t> q = a / d; ``` ### Minimal Example [https://godbolt.org/z/5Exo7Wrz3](https://godbolt.org/z/ozPeM3KT7)
issue