-
Notifications
You must be signed in to change notification settings - Fork 700
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
__IncompleteArrayField shouldn't implement Clone
/ Copy
.
#1431
Comments
Well, it's using the same semantics as C, bindgen doesn't know about whether it's a variable length array, or just a separator so bitfields pack differently, or something else. The following C code compiles also without problems: struct fam {
unsigned len;
int data[];
};
void use(const struct fam* unused) {};
void copy(const struct fam* fam)
{
struct fam cp = *fam;
use(&cp);
} In general bindgen tries not to make assumptions about your C code. |
More to the point, there's nothing bindgen can do about this particular case if you move your array, which will effectively not copy the extra space. And there's no way to make a type immovable itself, though I believe in newer rust versions you can use So even if we didn't derive |
@emilio I think you totally miss the point, |
Oh, I see what you mean. Yeah, I agree copying just the I agree we should probably fix that. It's trivial, assuming nothing depends on it. |
Clone
/ Copy
.
Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the If you intend to work on this issue, then add |
Sorry for the initial misunderstanding @Stargateur, I totally misread your example :) |
I'd like to take this issue to get familiar with the project. |
Hey @honggoff! Thanks for your interest in working on this issue. It's now assigned to you! |
Flexible array members are represented in the generated binding by a struct __IncompleteArrayField<T>. Since such members do not contain any information about how big they are, it is impossible to automatically clone or copy them, either in C or rust. Fixes rust-lang#1431.
It looks like the implementation for |
Flexible array members are represented in the generated binding by a struct __IncompleteArrayField<T>. Since such members do not contain any information about how big they are, it is impossible to automatically clone or copy them, either in C or rust. Fixes #1431.
I wonder if it's not a bug or something because you can't copy a FAM like that. This is not a pointer. As I expected this produce complete undefined behavior when you use Copy or Clone trait.
Fail completely. Or I missing something ?
The text was updated successfully, but these errors were encountered: