-
-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
redundant(?) double static_cast #134
Comments
Hello @danra, I believe what C++ Insights shows is correct. Have a look here: https://godbolt.org/z/FC_pXU. It shows the AST output of your example and a second version with the C-Style-Cast. In C++ Insights the second version leads to only one Andreas |
andreasfertig
added a commit
that referenced
this issue
Sep 28, 2019
…icit cast. Both issues raised that there is a second `static_cast` after a C-style cast. It turns out, that an `ImplicitCastExpr` has a method `isPartOfExplicitCast`. This method together which the `-show-all-implicit-casts` option is used to suppress the second cast per default.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following:
int a = (int)1.0;
translates into
int a = static_cast<int>(static_cast<int>(1.0));
See https://cppinsights.io/lnk?code=aW50IG1haW4oKQp7CiAgCWludCBhID0gKGludCkxLjA7Cn0=&std=cpp17&rev=1.0
AFAICS there is a redundant
static_cast<int>
here - unless this is what the compiler actually does internally (for some reason?)The text was updated successfully, but these errors were encountered: