Since `dynamic_pointer_cast` may fail and return nullptr, either use `checked_pointer_cast` from `lib/helper/checked_cast.h` if you are sure that all doneObservers are Tasks, or, alternatively write this as:

    if (auto task = std::dynamic_pointer_cast<Task>(doneObserver)) { ... push_back(task); ... }