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

VaList struct might not have foreign-function safe representation #3

Closed
pnkfelix opened this issue Feb 16, 2016 · 2 comments
Closed

Comments

@pnkfelix
Copy link

Currently when I do:

extern crate va_list;

extern {
    fn foo(args: va_list::VaList);
}

I get the following message from rustc:

% cargo build
   Compiling ffi-play v0.1.0 (file:///Users/fklock/Dev/Rust/ffi-play)
src/lib.rs:4:18: 4:33 warning: found struct without foreign-function-safe representation annotation in foreign module, consider adding a #[repr(C)] attribute to the type, #[warn(improper_ctypes)] on by default
src/lib.rs:4     fn foo(args: va_list::VaList);
                              ^~~~~~~~~~~~~~~

At first I took this as a sign that this crate merely needs to add #[repr(C)] attribute(s) in appropriate places.

However, eddyb on IRC pointed out that this might not suffice: https://botbot.me/mozilla/rust-internals/2016-02-16/?msg=60150124&page=4

In any case, it seems like the compiler warning is going to (perhaps rightfully) scare off users of this crate. So you may want to address it.

@richard-uk1
Copy link

Working with va_args is always going to be very unsafe. It relies on the particular implementation of the va_* macros. I've been through the implementation and I'm pretty sure this warning is a false-positive.

@thepowersgang
Copy link
Owner

Fixed with dac37e7 (hopefully for all architectures)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants