这是indexloc提供的服务,不要输入任何密码
Skip to content

Dangling references in basic_commands. #2

@tadashuai

Description

@tadashuai

auto& on_construct() noexcept {
return reg_->template on_construct<T>();
}

auto& on_update() noexcept {
return reg_->template on_update<T>();
}

auto& on_destruct() noexcept {
return reg_->template on_destruct<T>();
}

其中reg_->template on_construct<T>()reg_->template on_update<T>()reg_->template on_destruct<T>()返回的都是一个sink的临时变量,从而导致返回了悬垂引用,后续对这些悬垂引用的使用都是UB。
直接返回值就行了,编译器会执行RVO的。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions