Closed
Description
#![feature(core_intrinsics)]
struct A<T> {
x: T,
y: T,
z: T,
w: T,
}
fn f<T>(dummy: T) -> T {
unsafe {
let mut dest: T = std::mem::uninitialized();
std::intrinsics::volatile_store(&mut dest as *mut T, dummy);
std::intrinsics::volatile_load(&dest as *const T)
}
}
pub fn main() {
// Either
let (_, _, _, _) = f((1i32, 2i32, 3i32, 4i32));
// or
let _ = f(A {
x: 1i32,
y: 2,
z: 3,
w: 4,
});
}
Compiling with rustc
(rustc 1.6.0-dev (b14dc5bc1 2015-11-06)
) gets:
Stored value type does not match pointer operand type!
store volatile { i32, i32, i32, i32 }* %arg, { i32, i32, i32, i32 }* %dest, align 4
{ i32, i32, i32, i32 }LLVM ERROR: Broken function found, compilation aborted!
Or:
Stored value type does not match pointer operand type!
store volatile %"A<i32>"* %arg, %"A<i32>"* %dest, align 4
%"A<i32>" = type { i32, i32, i32, i32 }LLVM ERROR: Broken function found, compilation aborted!
It looks to me that volatile_store
's second argument's value is used without looking at platform ABI requirements (ie using the load).
volatile_load
might also be affected.
Also, LLVM error formatting weirdness.