Skip to content

link error for call to trivial C++ destructor #6502

@zygoloid

Description

@zygoloid

Testcase:

import Cpp inline "struct X {};";

fn Run() {
  var x: Cpp.X = {};
}

This fails to link with an undefined reference to X::~X. The problem is that the toolchain is generating a call to a trivial destructor, and Clang expects that trivial destructors are never called so doesn't generate definitions for them. Presumably we should avoid calling the C++ destructor in the case where it's trivial, perhaps by synthesizing a "no_op" builtin as Destroy.Op for X instead of a thunk that calls the C++ destructor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions