Skip to content

Slice length becomes random between nightly-2021-03-04 and nightly-2021-03-05 #82859

Closed
@juntyr

Description

@juntyr

Code

I tried this code (thanks to @jyn514 for the minified version):

fn impl_get_slice() -> &'static [()] {
    &[()]
}

#[inline(always)]
fn get_slice() -> &'static [()] {
    let ret = (|| { impl_get_slice() })();
    ret
}

fn main() {
    let output = get_slice().len();
    println!("{}", output);
}

I expected the code to print 0, the length of the slice.

Instead, a random value is printed.

Version it worked on

It most recently worked on:

rustc --version --verbose:

rustc 1.52.0-nightly (476acbf1e 2021-03-03)
binary: rustc
commit-hash: 476acbf1e9965b5e95c90f0d7d658709812b7003
commit-date: 2021-03-03
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1

Version with regression

rustc --version --verbose:

rustc 1.52.0-nightly (45b3c2851 2021-03-04)
binary: rustc
commit-hash: 45b3c28518e4c45dfd12bc2c4400c0d0e9639927
commit-date: 2021-03-04
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 12.0.0

@rustbot modify labels: +regression-from-nightly-to-nightly -regression-untriaged

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions