QStringRef: fix harmless truncation in compare_helper(U16/U8)
The return length1 truncated from qsizetype to int, which could, on
overflow, change sign (this is not undefined behaviour; it was
implementation-defined, and C++20 mandates two's complement). Still,
add a check to tst_qstringref.cpp.
The reason this is harmless is that length1 (unlike lendth2) always
comes from QStringRef::size(), which remains limited to int range.
Still, should be fixed, so use qtools_p.h's len_comp, which is what
QString's version uses, too.
Pick-to: 6.12 6.11 6.8
Change-Id: Iece279023bc4a919be2024ae146384c9d3cd2970
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>