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

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to