Explicitly support having a WeakRef to self
This commit is contained in:
@@ -445,3 +445,17 @@ TEST_CASE("Polymorphic edge cases") {
|
||||
CHECK(base_ref_from_weak.get() == derived_ref.get());
|
||||
}
|
||||
}
|
||||
|
||||
// Should be run with asan or valgrind
|
||||
TEST_CASE("Self-referencing WeakRef pattern") {
|
||||
struct AmIAlive {
|
||||
volatile int x;
|
||||
~AmIAlive() { x = 0; }
|
||||
};
|
||||
struct SelfReferencing {
|
||||
AmIAlive am;
|
||||
WeakRef<SelfReferencing> self_;
|
||||
};
|
||||
auto x = make_ref<SelfReferencing>();
|
||||
x->self_ = x;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user