[PATCH] D151187: [doc] Add casting style preference to coding standards
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 23 04:11:24 PDT 2023
jhenderson marked an inline comment as done.
jhenderson added a comment.
In D151187#4363915 <https://reviews.llvm.org/D151187#4363915>, @barannikov88 wrote:
> What about function style casts? I personally find them acceptable in limited cases, such as "constructing" int64_t from unsigned.
It's a fair question, and I don't have a good answer for this. Strictly, we should //probably// forbid them in new code on the basis that they are just as bad as C-style casts (they are explicitly defined to be identical), with regards to safety etc, but I also have used them in the past for the same "constructing" style like you find. Any suggestion on how we might codify the latter.
@mehdi_amini, do you have a preference?
================
Comment at: llvm/docs/CodingStandards.rst:1275
+ int x = 42;
+ long *y = static_cast<long *>(&x);
+ (void)y;
----------------
barannikov88 wrote:
> This does not compile.
>
Oops /facepalm. (Fixed now)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151187/new/
https://reviews.llvm.org/D151187
More information about the llvm-commits
mailing list