[D] Fix occasional undefined behaviour with inheritance hierarchies
Particularly when using virtual inheritance as the pointers weren't correctly upcast from derived class to base class when stored in the base's proxy class. Fixes commented out test code in cpp11_std_unique_ptr_runme and li_std_auto_ptr_runme D tests.
This commit is contained in:
parent
5a379d317b
commit
910fd1e3cf
8 changed files with 73 additions and 12 deletions
|
|
@ -10,6 +10,7 @@
|
|||
%inline %{
|
||||
#include <memory>
|
||||
#include <string>
|
||||
//#include <iostream>
|
||||
#include "swig_examples_lock.h"
|
||||
|
||||
class Klass {
|
||||
|
|
@ -53,8 +54,18 @@ struct KlassInheritance : virtual Klass {
|
|||
}
|
||||
};
|
||||
|
||||
std::string useKlassRawPtr(Klass* k) {
|
||||
// std::cout << "useKlassRawPtr " << std::hex << (Klass*)k << std::endl;
|
||||
std::string s(k->getLabel());
|
||||
// std::cout << "useKlassRawPtr string: " << s << std::endl;
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string takeKlassUniquePtr(std::unique_ptr<Klass> k) {
|
||||
return std::string(k->getLabel());
|
||||
// std::cout << "takeKlassUniquePtr " << std::hex << (Klass*)k.get() << std::endl;
|
||||
std::string s(k->getLabel());
|
||||
// std::cout << "takeKlassUniquePtr string: " << s << std::endl;
|
||||
return s;
|
||||
}
|
||||
|
||||
bool is_nullptr(Klass *p) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue