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

Failed layout test, when template is referencing opaque template #1018

Open
usamec opened this Issue Sep 22, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@usamec

usamec commented Sep 22, 2017

Input C/C++ Header

template<class T>
class B {
  T* x;
};

template<class T>
class A {
 public:
  void a();
  B<T> x;
};

template class A<double>;

Bindgen Invocation

$bindgen test_bind2.hpp -o src/bindings.rs --opaque-type "B" -- -x c++

Actual Results

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct B {
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct A {
    pub x: u8,
}
#[test]
fn __bindgen_test_layout_A_open0_double_close0_instantiation() {
    assert_eq!(::std::mem::size_of::<A>() , 8usize , concat ! (
               "Size of template specialization: " , stringify ! ( A ) ));
    assert_eq!(::std::mem::align_of::<A>() , 8usize , concat ! (
               "Alignment of template specialization: " , stringify ! ( A )
               ));
}

Expected Results

When running test we get

failures:

---- __bindgen_test_layout_A_open0_double_close0_instantiation stdout ----
        thread '__bindgen_test_layout_A_open0_double_close0_instantiation' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `8`: Size of template specialization: A', src/bindings.rs:14:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Apparently x: u8 is wrong.

When invoked without opaque inner type it works:

bindgen test_bind2.hpp -o src/bindings.rs -- -x c++
@fitzgen

This comment has been minimized.

Show comment
Hide comment
@fitzgen

fitzgen Sep 22, 2017

Collaborator

Thanks for the bug report!

Collaborator

fitzgen commented Sep 22, 2017

Thanks for the bug report!

@usamec

This comment has been minimized.

Show comment
Hide comment
@usamec

usamec Sep 22, 2017

Might be related to #652

usamec commented Sep 22, 2017

Might be related to #652

@usamec

This comment has been minimized.

Show comment
Hide comment
@usamec

usamec Sep 23, 2017

Reduced and updated the test case.

usamec commented Sep 23, 2017

Reduced and updated the test case.

@usamec usamec changed the title from Failed layout test when using std::map inside the template to Failed layout test, when template is referencing opaque template Sep 23, 2017

@fitzgen

This comment has been minimized.

Show comment
Hide comment
@fitzgen

fitzgen Sep 25, 2017

Collaborator

Thanks for providing a reduced test case!

Collaborator

fitzgen commented Sep 25, 2017

Thanks for providing a reduced test case!

@usamec

This comment has been minimized.

Show comment
Hide comment
@usamec

usamec Jan 22, 2018

Any progress on this?

usamec commented Jan 22, 2018

Any progress on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment