Skip to content

Improper virtual method tracking with template parameters. #691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
emilio opened this issue May 8, 2017 · 0 comments
Closed

Improper virtual method tracking with template parameters. #691

emilio opened this issue May 8, 2017 · 0 comments
Labels

Comments

@emilio
Copy link
Contributor

emilio commented May 8, 2017

Input C/C++ Header

class VirtualMethods {
  virtual void foo();
};

template<typename K>
class Set {
  int bar;
};

class ServoElementSnapshotTable
  : public Set<VirtualMethods>
{};

Bindgen Invokation

$ bindgen input.h

Actual Results

/* automatically generated by rust-bindgen */

#[repr(C)]
pub struct VirtualMethods__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug, Copy)]
pub struct VirtualMethods {
    pub vtable_: *const VirtualMethods__bindgen_vtable,
}
#[test]
fn bindgen_test_layout_VirtualMethods() {
    assert_eq!(::std::mem::size_of::<VirtualMethods>() , 8usize , concat ! (
               "Size of: " , stringify ! ( VirtualMethods ) ));
    assert_eq! (::std::mem::align_of::<VirtualMethods>() , 8usize , concat ! (
                "Alignment of " , stringify ! ( VirtualMethods ) ));
}
impl Clone for VirtualMethods {
    fn clone(&self) -> Self { *self }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Set {
    pub bar: ::std::os::raw::c_int,
}
#[repr(C)]
pub struct ServoElementSnapshotTable__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug, Copy)]
pub struct ServoElementSnapshotTable {
    pub vtable_: *const ServoElementSnapshotTable__bindgen_vtable,
    pub _base: Set,
}
#[test]
fn bindgen_test_layout_ServoElementSnapshotTable() {
    assert_eq!(::std::mem::size_of::<ServoElementSnapshotTable>() , 4usize ,
               concat ! (
               "Size of: " , stringify ! ( ServoElementSnapshotTable ) ));
    assert_eq! (::std::mem::align_of::<ServoElementSnapshotTable>() , 4usize ,
                concat ! (
                "Alignment of " , stringify ! ( ServoElementSnapshotTable )
                ));
}
impl Clone for ServoElementSnapshotTable {
    fn clone(&self) -> Self { *self }
}
#[test]
fn __bindgen_test_layout_Set_instantiation_13() {
    assert_eq!(::std::mem::size_of::<Set>() , 4usize , concat ! (
               "Size of template specialization: " , stringify ! ( Set ) ));
    assert_eq!(::std::mem::align_of::<Set>() , 4usize , concat ! (
               "Alignment of template specialization: " , stringify ! ( Set )
               ));
}

Expected Results

ServoElementSnapshotTable should have no vtable

@emilio emilio added the bug label May 8, 2017
bors-servo pushed a commit that referenced this issue May 8, 2017
ir: Don't assume template instantiation argument with vtable implies vtable

Fixes #691
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant