You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
template <int, typename> structa {};
enum { b };
namespaceJS {
template <typename c> using d = a<b, c>;
template <typename c> classe { d<c> f; };
classAutoIdVector : e<int> {};
}
Bindgen Invokation
$ bindgen input.hpp -- -std=c++14
Actual Results
/* automatically generated by rust-bindgen */pubconst b:_bindgen_ty_1 = _bindgen_ty_1::b;#[repr(u32)]#[derive(Debug,Copy,Clone,PartialEq,Eq,Hash)]pubenum_bindgen_ty_1{ b = 0,}pubtypeJS_d = ();#[repr(C)]pubstructJS_e{pubf:JS_d,}#[repr(C)]pubstructJS_AutoIdVector{pub_base:JS_e,}#[test]fnbindgen_test_layout_JS_AutoIdVector(){assert_eq!(::std::mem::size_of::<JS_AutoIdVector>(),1usize, concat ! ("Size of: ", stringify ! (JS_AutoIdVector)));assert_eq!(::std::mem::align_of::<JS_AutoIdVector>(),1usize, concat !
("Alignment of ", stringify ! (JS_AutoIdVector)));}#[test]fn__bindgen_test_layout_JS_e_instantiation_16(){assert_eq!(::std::mem::size_of::<JS_e>(),1usize, concat ! ("Size of template specialization: ", stringify ! (JS_e)));assert_eq!(::std::mem::align_of::<JS_e>(),1usize, concat ! ("Alignment of template specialization: ", stringify ! (JS_e)));}
Compiling with --test and running the generated layout tests results in these failures:
running 2 tests
test root::JS::bindgen_test_layout_AutoIdVector ... FAILED
test root::__bindgen_test_layout_e_instantiation_16 ... FAILED
failures:
---- root::JS::bindgen_test_layout_AutoIdVector stdout ----
thread 'root::JS::bindgen_test_layout_AutoIdVector' panicked at 'assertion failed: `(left == right)` (left: `0`, right: `1`): Size of: AutoIdVector', ./js.rs:22
note: Run with `RUST_BACKTRACE=1` for a backtrace.
---- root::__bindgen_test_layout_e_instantiation_16 stdout ----
thread 'root::__bindgen_test_layout_e_instantiation_16' panicked at 'assertion failed: `(left == right)` (left: `0`, right: `1`): Size of template specialization: root :: JS :: e', ./js.rs:31
failures:
root::JS::bindgen_test_layout_AutoIdVector
root::__bindgen_test_layout_e_instantiation_16
test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured
Expected Results
Although we generally can't support non-type template parameters and instantiations of templates with such parameters, we shouldn't be generating code + layout tests that fail. We need to do a better job of detecting this and emitting an opaque blob instead, or even completely skipping this stuff in codegen (which we do some of the time but not always it seems).
The text was updated successfully, but these errors were encountered:
When instantiating templates whose definitions have non-type generic parameters,
prefer the layout of the instantiation type to the garbage we get from the
definition's layout. In general, an instantiation's layout will always be a
better choice than the definition's layout, regardless of non-type parameters.
Fixesrust-lang#569
Generate better opaque blobs in the face of non-type parameters
When instantiating templates whose definitions have non-type generic parameters, prefer the layout of the instantiation type to the garbage we get from the definition's layout. In general, an instantiation's layout will always be a better choice than the definition's layout, regardless of non-type parameters.
Fixes#569
r? @emilio
Input C/C++ Header
Bindgen Invokation
Actual Results
Compiling with
--test
and running the generated layout tests results in these failures:Expected Results
Although we generally can't support non-type template parameters and instantiations of templates with such parameters, we shouldn't be generating code + layout tests that fail. We need to do a better job of detecting this and emitting an opaque blob instead, or even completely skipping this stuff in codegen (which we do some of the time but not always it seems).
The text was updated successfully, but these errors were encountered: