cppinsights
cppinsights copied to clipboard
Static casts missing with inherited classes
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)))));