[Development] qsizetype

Ahmad Samir a.samirh78 at gmail.com
Thu Mar 9 12:22:10 CET 2023


On 9/3/23 10:14, Marc Mutz via Development wrote:
> On 08.03.23 15:30, Ahmad Samir wrote:
>> 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)
> 
> In which situation would you want to search for all casts in a piece of source
> code? Without the use of a semantic grep tool?
> 

The tool (in this case compiling with -Wshorten-64-to-32, then checking with 
clangd or the build log ...etc) would warn about implicit casts, but not explicit 
ones? now if there is a named cast, then I can search for that much easier than I 
would for the C-style cast (int)foo, or int(foo).

(I haven't checked clang-tidy, but I am guessing it won't be that much different 
than clangd).

> I wouldn't like the extra noise of a static_cast when a constructor call
> would suffice. Obviously, C-style casts should be avoided (in headers,
> IIRC, they're caught by headerscheck).
> 

Good luck with avoiding C-style casts in a huge codebase, e.g. qtbase, there is 
code that's been there since the 90's, and any attempt to "fix" C-style casts in 
the whole codebase would be seen as "churn".

> Thanks,
> Marc
> 

Thanks,
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/20230309/c843689c/attachment.sig>


More information about the Development mailing list