Skip to content
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
Open

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

usamec opened this issue Sep 22, 2017 · 5 comments

Comments

@usamec
Copy link

@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
Copy link
Member

@fitzgen fitzgen commented Sep 22, 2017

Thanks for the bug report!

@usamec
Copy link
Author

@usamec usamec commented Sep 22, 2017

Might be related to #652

@usamec
Copy link
Author

@usamec usamec commented Sep 23, 2017

Reduced and updated the test case.

@usamec usamec changed the title Failed layout test when using std::map inside the template Failed layout test, when template is referencing opaque template Sep 23, 2017
@fitzgen
Copy link
Member

@fitzgen fitzgen commented Sep 25, 2017

Thanks for providing a reduced test case!

@usamec
Copy link
Author

@usamec 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants