Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upZero-sized functions pointers no longer variadic-compatible #32201
Comments
alexcrichton
added
the
regression-from-stable-to-nightly
label
Mar 11, 2016
This comment has been minimized.
This comment has been minimized.
|
triage: I-nominated |
alexcrichton
added
I-nominated
T-compiler
labels
Mar 11, 2016
This comment has been minimized.
This comment has been minimized.
|
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... |
This comment has been minimized.
This comment has been minimized.
|
/me sighs. Hate variadics. I imagine though that we could do some sort of special case for |
This comment has been minimized.
This comment has been minimized.
|
I think we should force a small set of types in |
This comment has been minimized.
This comment has been minimized.
|
triage: P-high |
rust-highfive
added
P-high
and removed
I-nominated
labels
Mar 17, 2016
This comment has been minimized.
This comment has been minimized.
|
Shouldn't it be sufficient to restrict the arguments to variadic C functions to repr(C) things? |
alexcrichton
referenced this issue
Mar 29, 2016
Closed
Incorrect behavior calling extern "C" varargs functions in nightly (works in 1.8 beta) #32588
pnkfelix
assigned
eddyb
Mar 31, 2016
This comment has been minimized.
This comment has been minimized.
|
Turns out we do have some checks related to promotions, instead of actually performing them. |
eddyb
referenced this issue
Apr 8, 2016
Merged
Blacklist fn item types from being used with variadic functions. #32816
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Apr 8, 2016
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Apr 8, 2016
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Apr 8, 2016
This comment has been minimized.
This comment has been minimized.
|
@eddyb Should we also blacklist fat pointers? |
alexcrichton commentedMar 11, 2016
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-rustwhich defines variadic functions.cc @eddyb, @nikomatsakis