You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current vtable code generation uses references instead of pointers for this.
I think this should be changed as C++ mutable references are semantically different from rust's ones. And with the current implementation it's impossible to avoid UB in certain edge cases.
Multithreaded C++ code calling rust always results in the creation of a mutable reference unless the function is marked const, if multiple calls happen at once we would have more than one mutable reference around. Mutable aliasing here is unavoidable.
The solution would be to use pointers instead of references, as they have basically the same semantics as C++ mutable references and don't create such problems.
Also, pointers offer greater flexibility when it comes to casting between types, which happens a lot around rust implemented C++ interfaces.
The only disadvantage is loosing the guarantee that this must always be not null. A possible fix would be to use NonNull<T> for this, but since there is no const equivalent of NonNull<T> I don't think this is a viable solution.
The text was updated successfully, but these errors were encountered:
The current vtable code generation uses references instead of pointers for
this
.I think this should be changed as C++ mutable references are semantically different from rust's ones. And with the current implementation it's impossible to avoid UB in certain edge cases.
Multithreaded C++ code calling rust always results in the creation of a mutable reference unless the function is marked const, if multiple calls happen at once we would have more than one mutable reference around. Mutable aliasing here is unavoidable.
The solution would be to use pointers instead of references, as they have basically the same semantics as C++ mutable references and don't create such problems.
Also, pointers offer greater flexibility when it comes to casting between types, which happens a lot around rust implemented C++ interfaces.
The only disadvantage is loosing the guarantee that
this
must always be not null. A possible fix would be to useNonNull<T>
forthis
, but since there is no const equivalent ofNonNull<T>
I don't think this is a viable solution.The text was updated successfully, but these errors were encountered: