Closed mkolin closed 2 years ago
This may be related to https://github.com/wlav/cppyy/issues/66
Yes, this is the same as #66. The point being that T*
can be auto-downcasted, but const T*&
(the actual return type of vector indexing) can not. After all, in the latter case, if the pointer is updated, and that change propagated through the reference, then the new instance pointed to by the base class pointer could be of a different derived type. This one, like #66, requires some thinking as clearly the correct transliteration doesn't line up with most probable expected behavior.
Fixed in repo by distinguishing the behaviors between const and non-const. It fixes this report and doesn't break any tests, but there may still be corner cases lurking.
Released with 2.4.0 and its dependencies.
The behavior of a vector of base pointers may behave differently depending on how it gets called or how a base class is defined. It will sometimes return the base and sometimes return the derived type.
This falls into at least three cases:
All three of these cases will return the base if there is no vtable. This is fine, it just threw me when constructing the tests. Also, the behavior has somewhat changed since 1.6.1.
Example:
In 2.3.1 we get this output:
In 1.6.1 we get this output:
Any help would be appreciated. Thanks!