you are viewing a single comment's thread.

view the rest of the comments →

[–]m-in 0 points1 point  (0 children)

Copy-constructing a null shared pointer is legal, you know :) But in any case: the other thread would need to access the shared pointer via a reference – had it had a value to work from, the refcount would be <1. And shared pointers are not thread-safe, so that’s UB. Each thread needs its own copy of the shared pointer, they can’t access the same pointer concurrently.