-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Zero-sized functions pointers no longer variadic-compatible #32201
Comments
triage: I-nominated |
I... can't even: extern {
fn printf(_: *const u8, ...);
}
pub fn main() {
unsafe {
printf("'%s' has length %d\0".as_ptr(), "foobar\0");
}
}
Works on playpen, shows no warnings... |
/me sighs. Hate variadics. I imagine though that we could do some sort of special case for |
I think we should force a small set of types in |
triage: P-high |
Shouldn't it be sufficient to restrict the arguments to variadic C functions to repr(C) things? |
Turns out we do have some checks related to promotions, instead of actually performing them. |
Fixes rust-lang#32201 by adding fn types to the variadic blacklist which currently includes `bool`, `i8`, `u8`, `i16`, `u16` and `f32`.
@eddyb Should we also blacklist fat pointers? |
Blacklist fn item types from being used with variadic functions. Fixes rust-lang#32201 by adding fn types to the variadic blacklist which currently includes `bool`, `i8`, `u8`, `i16`, `u16` and `f32`.
Blacklist fn item types from being used with variadic functions. Fixes #32201 by adding fn types to the variadic blacklist which currently includes `bool`, `i8`, `u8`, `i16`, `u16` and `f32`.
Seems like a crazy edge case, but this code works on stable but is currently broken on nightly.
On stable Rust, this produces the IR:
whereas on nightly it looks like:
Which is clearly bad! I noticed there's a warning for transmuting function types to function pointers (as now it's 0-sized to pointer-sized), but perhaps the same warning could be appplied here? Or better could the coercion be automatically applied?
For reference this was discovered in
curl-rust
which defines variadic functions.cc @eddyb, @nikomatsakis
The text was updated successfully, but these errors were encountered: