| 1 | #include <atomic> |
| 2 | |
| 3 | // Define a Parent and Child struct that can point to each other. |
| 4 | class Parent; |
| 5 | struct Child { |
| 6 | // This should point to the parent which in turn owns this |
| 7 | // child instance. This cycle should not cause LLDB to infinite loop |
| 8 | // during printing. |
| 9 | std::atomic<Parent*> parent{nullptr}; |
| 10 | }; |
| 11 | struct Parent { |
| 12 | Child child; |
| 13 | }; |
| 14 | |
| 15 | struct S { |
| 16 | int x = 1; |
| 17 | int y = 2; |
| 18 | }; |
| 19 | |
| 20 | int main () |
| 21 | { |
| 22 | std::atomic<S> s; |
| 23 | s.store(i: S()); |
| 24 | std::atomic<int> i; |
| 25 | i.store(i: 5); |
| 26 | |
| 27 | Parent p; |
| 28 | // Let the child node know what its parent is. |
| 29 | p.child.parent = &p; |
| 30 | |
| 31 | return 0; // Set break point at this line. |
| 32 | } |
| 33 | |
| 34 | |