Skip to content

[util.smartptr.shared.cast] "Will eventually" is so sure #7035

Closed
@zhihaoy

Description

@zhihaoy

There're four occurrences of "will eventually" in this section, for instance

[Note 1 : The seemingly equivalent expression shared_ptr<T>(static_cast<T*>(r.get())) will eventually
result in undefined behavior, attempting to delete the same object twice. --end note]

But what does it mean? If r.get() compares equal to nullptr, the program won't delete the same object twice. Moreover, in dynamic_pointer_cast's case, the program may run "correctly" sometimes if the users handled the case when dynamic_cast gives nullptr...

Suggestion:

- will eventually result in undefined behavior,
+ can result in undefined behavior,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions