Skip to content
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

Static casts missing with inherited classes #639

Open
nevesnunes opened this issue May 12, 2024 · 0 comments
Open

Static casts missing with inherited classes #639

nevesnunes opened this issue May 12, 2024 · 0 comments

Comments

@nevesnunes
Copy link

Not sure if this is one of the cases where non-compilable output is expected.

I came across this snippet where a class is defined with multiple inheritances, and then offsets of inherited objects are read after casting through all inheritance levels.

C++ Insights is only outputting the last class static_cast for each printf, so the first one will look like this:

printf("%c", static_cast<int>(static_cast<char>((reinterpret_cast<long *>(static_cast<A *>(&c)) - reinterpret_cast<long *>(&c)))));

g++ 12.2.0 error:

hello.cc:117:96: error: ‘main()::A’ is an ambiguous base of ‘main()::O’           
  117 | static_cast<char>((reinterpret_cast<long *>(static_cast<A *>(&c)) - reinter
pret_cast<long *>(&c)))));  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant