Closed
Description
I tried this code:
[build-dependencies]
cc = "1.0.83"
// /build.rs
fn main() {
cc::Build::new()
.compiler("/usr/bin/clang-16")
.file("./src/abc.c")
.opt_level(0)
.compile("abc");
}
// /src/abc.c
float test() {
_Float16 y = 114;
float z = y;
return z;
}
// /src/main.rs
extern "C" {
fn test() -> f32;
}
fn main() {
println!("{}", unsafe { test() });
}
I expected to see this happen: It prints 114
.
Instead, this happened: It prints an unknown value, 0.00017929077
, -0.045898438
or other.
After debugging, I found both compiler_builtins
and libgcc
provide the symbol __extendhfsf2
. __extendhfsf2
is a compiler-rt
intrinsics for casting a _Float16
to float
. In compiler_builtins
, the only argument of __extendhfsf2
is passed in a general-proposed register, However, in libgcc
, the only argument of __extendhfsf2
is passed in xmm
.
related: llvm/llvm-project#56854
Meta
rustc --version --verbose
:
rustc 1.74.1 (a28077b28 2023-12-04)
binary: rustc
commit-hash: a28077b28a02b92985b3a3faecf92813155f1ea1
commit-date: 2023-12-04
host: x86_64-unknown-linux-gnu
release: 1.74.1
LLVM version: 17.0.4
Metadata
Metadata
Assignees
Labels
Area: Floating point numbers and arithmeticArea: linking into static, shared libraries and binariesCategory: This is a bug.Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessHigh priorityRelevant to the compiler team, which will review and decide on the PR/issue.