Closed
Description
Summary:
The following piece of code fail when compiled to wasm32-unknown-unknown since nightly-2019-07-18. This nightly introduces https://github.com/rust-lang/rust/pull/62592/files so probably related.
Regression test:
pub fn get() -> u128 {
let d = [0, 0, 32, 59, 157, 181, 5, 111, 0, 0, 0, 0, 0, 0, 0, 0];
decode_impl(&mut &d[..]).unwrap()
}
#[no_mangle]
fn main() {
let c: u128 = get();
assert_eq!(c, 8000000000000000000u128);
}
#[inline(never)]
fn decode_impl(input: &mut &[u8]) -> Result<u128, ()> {
let mut buf = [0u8; 16];
read(input, &mut buf)?;
Ok(<u128>::from_le_bytes(buf))
}
#[inline(never)]
fn read(input: &mut &[u8], into: &mut [u8]) -> Result<(), ()> {
if into.len() != input.len() {
return Err(());
}
into.copy_from_slice(&input[..]);
Ok(())
}
with configuration:
[lib]
name = "code"
crate-type = [
"cdylib",
"rlib",
]
[profile.release]
opt-level = "z"
Reproduce:
see the repo: https://github.com/thiolliere/wasm-llvm9-issue it contains:
- javascript file
t.js
used to execute test with node. make.sh
file to execute the test on rust version 2019-07-17 and 2019-07-18.
Notes:
- probably introduced by https://github.com/rust-lang/rust/pull/62592/files
- if you remove either
"rlib"
oropt-level = "z"
it works (it is not failing anymore)
cc @pepyakin
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Category: This is a bug.Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessTarget: WASM (WebAssembly), http://webassembly.org/Medium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from stable to beta.