Skip to content

C++ foreign type's dtor needs to be invoked on moved-from objects #77894

@Xazax-hun

Description

@Xazax-hun

Description

When passing a type imported from C++ to a consuming Swift function (or a C++ foreign API taking an rvalue reference), the caller is still responsible for destroying the object (calling the dtor) regardless whether the object.

Reproduction

let x = getCppMoveOnlyType()
consumingFunction(x)

Expected behavior

The dtor for x is invoked after the last use.

Environment

swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++clang importerArea → compiler: The clang importercompilerThe Swift compiler itselfownershipFeature: Ownership modifiers and semanticsswift 6.0unexpected behaviorBug: Unexpected behavior or incorrect output

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions