Skip to content

bindgen does not generate destructors if the class inherits a virtual destructor #1843

Open
@Volker-Weissmann

Description

@Volker-Weissmann

Input C/C++ Header

class Parent {
public:
	virtual ~Parent();
};
class Child: Parent {
public:
	Child();
	~Child();
};

Bindgen Invocation

bindgen::Builder::default()
        .header("wrapper.hpp")
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        .clang_arg("-x")
        .clang_arg("c++")
        .generate()

Actual Results

... more code...
impl Child {
    #[inline]
    pub unsafe fn new() -> Self {
        let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
        Child_Child(__bindgen_tmp.as_mut_ptr());
        __bindgen_tmp.assume_init()
    }
}
extern "C" {
    #[link_name = "\u{1}_ZN5ChildD1Ev"]
    pub fn Child_Child_destructor(this: *mut Child);
}

Expected Results

There should be a "pub unsafe fn destruct(&mut self)" in the "impl Child" section.
Note: In C++, first the virtual Parent destructor is callend then the Child 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