-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
C-external-bugCategory: issue that is caused by bugs in software beyond our controlCategory: issue that is caused by bugs in software beyond our controlO-x86_32Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)
Description
I tried this code:
#[repr(C)]
#[derive(Clone)]
struct S {
x: u8,
y: i32,
}
#[link(name = "extern", kind = "dylib")]
extern "fastcall" {
fn fastcall_fn(a: S, b: i32);
}
fn main() {
unsafe {
fastcall_fn(S { x: 1, y: 2 }, 16);
}
}
linked against the following C code (compiled to extern.dll
):
#include <stdio.h>
#include <stdint.h>
struct S {
uint8_t x;
int32_t y;
};
__declspec(dllexport) void __fastcall fastcall_fn(struct S s, int i) {
printf("fastcall_fn(S { x: %d, y: %d }, %d)\n", s.x, s.y, i);
fflush(stdout);
}
I expected to see this output:
fastcall_fn(S { x: 1, y: 2 }, 16)
Instead, I got this output:
fastcall_fn(S { x: 1, y: 2 }, 18873345)
fastcall_fn(S { x: 1, y: 2 }, 29491201)
Meta
rustc --version --verbose
:
rustc 1.58.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: i686-pc-windows-gnu
release: 1.58.0-dev
LLVM version: 13.0.0
Reproed against commit 7b3cd07 of master.
To reproduce, check out the fastcall-bug branch on my fork of rustc; the reproduction case is in src/test/run-make/fastcall-bug.
Metadata
Metadata
Assignees
Labels
C-external-bugCategory: issue that is caused by bugs in software beyond our controlCategory: issue that is caused by bugs in software beyond our controlO-x86_32Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)