-
Notifications
You must be signed in to change notification settings - Fork 682
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
Emit wrong layout with inheriting from zero-sized type parameters #586
Comments
I don't know how could we possibly fix this without monomorphization tbh. I'd also expect this to fail: class Foo {
virtual void vtable();
};
template<typename T>
class Bar : public T {}; |
Mainly, the code we should generate for the template depends on the actual argument. |
I would hope that libclang would give us a layout for a concrete instantiation, though. Haven't dug into it yet, however. |
Cleaned up test case: // bindgen-flags: -- -std=c++14
class Base {};
template <class BaseT>
class CallArgsBase : BaseT {
int *c;
unsigned d;
};
class CallArgs : CallArgsBase<Base> {}; I'm not sure what is going on here and why the expected layout is size 16. Does C++ allow zero-sized base classes as long as the derived class is not zero sized? If so, then I think we're hosed. |
Yes
and yes |
Filed #851 for this version |
With non- #![feature(untagged_unions)]
use std::mem;
struct Inherits<T> {
_base: AtLeastOneByte<T>,
}
union AtLeastOneByte<T> {
t: T,
_address: u8,
}
struct SizedFoo {
x: usize,
y: usize,
}
struct UnsizedBar;
fn main() {
println!("size of Inherits<SizedFoo> = {}", mem::size_of::<Inherits<SizedFoo>>());
println!("size of Inherits<UnsizedBar> = {}", mem::size_of::<Inherits<UnsizedBar>>());
} Emits:
Although we would need to actually emit two versions of |
Input C/C++ Header
Bindgen Invokation
Actual Results
Compiles into this:
And results in this layout test failure:
Expected Results
Maybe opaque blobs, but never any layout test failures.
The text was updated successfully, but these errors were encountered: