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>
commitf2ac9e64f76105e7ec1ec6c372913ca571d27a19
parentef115df5d1665d203f33c0deb16461533309ca00
authorMarc Mutz <marc.mutz@qt.io>
committerMarc Mutz <marc.mutz@qt.io>
commit timeMon, 17 Aug 2026 15:41:10 +0000