[Development] Compare signed and unsigned integers in Qt

Thiago Macieira thiago.macieira at intel.com
Mon Aug 12 17:15:32 CEST 2024


On Monday 12 August 2024 04:57:56 GMT-7 Tatiana Borisova via Development 
wrote:
> The backport gives to Qt users a possibility to start using the safe
> comparison with C++17 and since Qt 6.9. The 'q20' namespace checks if std
> implementation is available and takes it, otherwise it takes our
> implementation.
> 
> How to use it: https://codereview.qt-project.org/c/qt/qtbase/+/578720
> In short, I hope it can be useful for development. And let's use the API
> (when it's suitable).
> 
> Also, I am thinking about better detection methods. A clang-tidy tool is a
> potential candidate.

Please make sure to understand anywhere you change before you change it. Not 
all signed/unsigned comparisons need to get the negative treatment with 
intcmp(): they may be intended to be converted to the unsigned type and 
compared like that. In those cases, to silence the tidy tool, you should cast 
the signed type to the unsigned equivalent and not use intcmp().


-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Principal Engineer - Intel DCAI Platform & System Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20240812/34258b75/attachment-0001.bin>


More information about the Development mailing list