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

core::ffi::VaList does not pass improper_ctypes lint #58280

Closed
dlrobertson opened this issue Feb 8, 2019 · 3 comments · Fixed by #58938
Closed

core::ffi::VaList does not pass improper_ctypes lint #58280

dlrobertson opened this issue Feb 8, 2019 · 3 comments · Fixed by #58938

Comments

@dlrobertson
Copy link
Contributor

dlrobertson commented Feb 8, 2019

Summary

On x86_64, Aarch64, and PowerPC core::ffi::VaList will not pass the improper_ctypes lint, but it should.

Example

Given the following:

#![no_std]
#![feature(c_variadic)]
#![deny(improper_ctypes)]
use core::ffi::VaList;

extern "C" {
    pub fn some_fn(_: i32, _: VaList);
}

The compiler will yield:

error: `extern` block uses type `()` which is not FFI-safe: tuples have unspecified layout
 --> test.rs:7:31
  |
7 |     pub fn some_fn(_: i32, _: VaList);
  |                               ^^^^^^
  |
note: lint level defined here
 --> test.rs:3:9
  |
3 | #![deny(improper_ctypes)]
  |         ^^^^^^^^^^^^^^^
  = help: consider using a struct instead

error: aborting due to previous error

Description

The implementation of VaListImpl for the x86_64, Aarch64, and PowerPC architectures uses *mut () or *const () as the pointer type for the pointers to the architecture specific save areas (e.g., the x86_64 implementation).

@dlrobertson
Copy link
Contributor Author

core::ffi defines c_void. Perhaps c_void should be used instead of ()

@nagisa
Copy link
Member

nagisa commented Feb 9, 2019

It would be fine to just special-case the va_list language item in the lint implementation.

@dlrobertson
Copy link
Contributor Author

It would be fine to just special-case the va_list language item in the lint implementation.

This seems reasonable to me too. The VaList structure should (for obvious reasons) always be FFI safe.

Centril added a commit to Centril/rust that referenced this issue Mar 10, 2019
core: ensure VaList passes improper_ctypes lint

Ensure the `core::ffi::VaList` structure passes the `improper_ctypes` lint.

Fixes: rust-lang#58280
Centril added a commit to Centril/rust that referenced this issue Mar 10, 2019
core: ensure VaList passes improper_ctypes lint

Ensure the `core::ffi::VaList` structure passes the `improper_ctypes` lint.

Fixes: rust-lang#58280
Centril added a commit to Centril/rust that referenced this issue Mar 10, 2019
core: ensure VaList passes improper_ctypes lint

Ensure the `core::ffi::VaList` structure passes the `improper_ctypes` lint.

Fixes: rust-lang#58280
Centril added a commit to Centril/rust that referenced this issue Mar 10, 2019
core: ensure VaList passes improper_ctypes lint

Ensure the `core::ffi::VaList` structure passes the `improper_ctypes` lint.

Fixes: rust-lang#58280
Centril added a commit to Centril/rust that referenced this issue Mar 11, 2019
core: ensure VaList passes improper_ctypes lint

Ensure the `core::ffi::VaList` structure passes the `improper_ctypes` lint.

Fixes: rust-lang#58280
kennytm added a commit to kennytm/rust that referenced this issue Mar 11, 2019
core: ensure VaList passes improper_ctypes lint

Ensure the `core::ffi::VaList` structure passes the `improper_ctypes` lint.

Fixes: rust-lang#58280
kennytm added a commit to kennytm/rust that referenced this issue Mar 15, 2019
core: ensure VaList passes improper_ctypes lint

Ensure the `core::ffi::VaList` structure passes the `improper_ctypes` lint.

Fixes: rust-lang#58280
kennytm added a commit to kennytm/rust that referenced this issue Mar 16, 2019
core: ensure VaList passes improper_ctypes lint

Ensure the `core::ffi::VaList` structure passes the `improper_ctypes` lint.

Fixes: rust-lang#58280
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

Successfully merging a pull request may close this issue.

2 participants