[Development] qsizetype

Ahmad Samir a.samirh78 at gmail.com
Wed Mar 8 15:30:24 CET 2023

On 1/9/22 12:15, Marc Mutz wrote:
> This should be non-issue for function parameters, because widening isn't
> an error. The value is less pronounced for return values, because
> widening those may cause narrowing in user code, but the hope is that
> once we've progressed somewhat, we can enlist compiler support by
> globally enabling warnings such as -Wshorten-64-to-32, even though, as
> the porting guide included in the
> https://bugreports.qt.io/browse/QTBUG-102461  epic describes, this will
> not catch manual casts, which is why, sadly, one needs to look at every
> int/uint manually.

Sorry for bringing this thread back up from the archives.

So, named casts (static_cast) are better in such cases, as searching for them in 
source code is much easier than searching for:
- int(foo)
- (int)foo
- (int)(foo)

multiplied by the number of other integral types in Qt (qint32, qint64, uint, 
qlonglong, qulonglong... etc).

Ahmad Samir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 236 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230308/a2fc8bb9/attachment-0001.sig>

More information about the Development mailing list