Spot the bug in the job hierarchy

from Inheritance
C++23 intermediate 4 min 1 issue to find

Find the lifetime bug in this generated job hierarchy.

C++
#include <memory>
#include <string>
#include <utility>

class Job {
public:
    virtual void run() = 0;
    ~Job() = default;
};

class FileJob final : public Job {
public:
    explicit FileJob(std::string path) : path_(std::move(path)) {}
    void run() override {}
private:
    std::string path_;
};

std::unique_ptr<Job> make_job() {
    return std::make_unique<FileJob>("report.csv");
}
Open in playground
Report an error