Closed
Description
When trying to look at how aggregates are passed to functions I came across the following:
The code presented below erroneously outputs 488447261
instead of 20
.
This is using the 1.9.0 preview release (or anything newer) and seems to be a regression from 1.8.0.
The behaviour only occurs when using the C calling conventions and optimizations, eliminating either factor gives the correct result.
#[repr(C)]
struct S {
a: u32,
b: f32,
c: u32
}
extern "C" fn test(s: S) -> u32 {
s.a + s.b as u32 + s.c
}
fn main() {
println!("{}", test(S { a: 12, b: 3.4, c: 5 }));
}