Bindgen struct offset error

#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
    ["Size of BView"][::std::mem::size_of::<BView>() - 272usize];
    ["Alignment of BView"][::std::mem::align_of::<BView>() - 8usize];
    ["Offset of field: BView::_unused_int1"][::std::mem::offset_of!(BView, _unused_int1) - 76usize];

At this point, rustc fails with index out of bounds: the length is 1 but the index is 4

I have only the vaguest idea what I'm looking at here. I'm up to a couple dozen include files here, and up to this one, it seemed to be working fine. Any clue what the source of the problem might be?

_unused_int1: i32 is indeed the first struct data item, after several hundred member functions. The rust struct lists it second, after a _base item declaring the base class.

I think no one who would this interface cares. The struct data values are all private, and the struct object will always be allocated by C++, so I can probably just remove this section and move on?

Can you share the complete code or at least the full error message?

To me, it sounds like bindgen is using this private/non-accessible code to run compile-time assertions.
I would rather understand the core issue (not just delete the offending checks) to make sure you don't run into issues later.

As the previous reply asks, do you have a minimal example? The input into bindgen would be nice, but at least the full source code and the full rustc error output.

Thanks, I will keep an eye out for a way to produce a practical example. The input here is only 841 lines, but there are of course lots more dragged in, and the bindgen output is 12,500 lines. And it isn't really much different from the other couple dozen files I've been through so far.

That was the full error message. Well, strictly speaking, there was a truncated quote of the code line, a row of carets (^) indicating the entire width of the line, and a reference to E0080 in case I wanted to know why array out of bounds indexing doesn't meet with approval in Rust.

To me, it appears that this ... expression, whatever it is ... is an alignment record to allow references to struct items. Which we really don't need, and I could as well delete the data items from the struct. [edit] I see bindgen --opaque-type does just that, and rustc is good with it. [/edit] I don't know what the "invented here" _base: Base_Class item is for, at the top, but I see no reference to it, so it can go, too. I will need to use base class information, to set up anything like C++ dispatching, but that will need more information than I can get from the bindgen output.

I was a little concerned that it might be needed for vtable access, but it doesn't look like there's any useful vtable access (with or without --vtable-generation), so that's not to worry about.