Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM_ERROR: invalid bitcast: transmute #110005

Closed
matthiaskrgr opened this issue Apr 6, 2023 · 1 comment · Fixed by #110021
Closed

LLVM_ERROR: invalid bitcast: transmute #110005

matthiaskrgr opened this issue Apr 6, 2023 · 1 comment · Fixed by #110021
Assignees
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

fn main() {
    let x: Option<Box<[u8]>> = unsafe {
        let z = (0usize, true);
        std::mem::transmute::<(usize, bool), Option<Box<[u8]>>>(z)
    };
}

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (2eaeb1eee 2023-04-05)
binary: rustc
commit-hash: 2eaeb1eee1b21772de8b935236d16ff8e03fdcf5
commit-date: 2023-04-05
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 16.0.0

Error output

<output>
Backtrace

warning: unused variable: `x`
 --> treereduce.out:2:9
  |
2 |     let x: Option<Box<[u8]>> = unsafe {
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

Invalid bitcast
  %7 = bitcast i8 %6 to i64
in function _ZN10treereduce4main17haa15f44c7ccefff9E
LLVM ERROR: Broken function found, compilation aborted!

@matthiaskrgr matthiaskrgr added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Apr 6, 2023
@matthiaskrgr
Copy link
Member Author

#109843 cc @scottmcm

@scottmcm scottmcm self-assigned this Apr 6, 2023
@scottmcm scottmcm added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Apr 7, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 7, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 10, 2023
…rors

Fix a couple ICEs in the new `CastKind::Transmute` code

Check the sizes of the immediates, rather than the overall types, when deciding whether we can convert types without going through memory.

Fixes rust-lang#110005
Fixes rust-lang#109992
Fixes rust-lang#110032
cc `@matthiaskrgr`
@bors bors closed this as completed in 454bca5 Apr 10, 2023
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants