Skip to content

LLVM ERROR: Too many bits for int64_t #112770

Closed as duplicate
Closed as duplicate

Description

@matthiaskrgr

Code

#![feature(repr128)]
#[derive(PartialEq, Debug)]
#[repr(i128)]
enum Test {
    A(Box<u64>) = 0,
    B(usize) = u64::MAX as i128 + 1,
}

fn main() {
    assert_ne!(Test::A(Box::new(2)), Test::B(0));
    // This previously caused a segfault.
    //
    // See https://github.com/rust-lang/rust/issues/70509#issuecomment-620654186
    // for a detailed explanation.
}

Meta

rustc --version --verbose:

0c2c243342ec2a2427f0624fac5ac59f0ee6fbcd

Error output

warning: the feature `repr128` is incomplete and may not be safe to use and/or cause compiler crashes
 --> 100612.rs:1:12
  |
1 | #![feature(repr128)]
  |            ^^^^^^^
  |
  = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information
  = note: `#[warn(incomplete_features)]` on by default
Backtrace

rustc: /home/matthias/vcs/github/rust_debug_assertions/src/llvm-project/llvm/include/llvm/ADT/APInt.h:1519: int64_t llvm::APInt::getSExtValue() const: Assertion `getSignificantBits() <= 64 && "Too many bits for int64_t"' failed.
[2]    32637 IOT instruction  RUST_BACKTRACE=full ~/.rustup/toolchains/local-debug-assertions/bin/rustc

Activity

  1. added
    I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way
    on Jun 18, 2023
  2. compiler-errors commented on Jun 18, 2023

    @compiler-errors
    Contributor

    What platform are you running this on? I can't repro this with a custom-built LLVM with debug assertions enabled on x86_64-unknown-linux-gnu.

  3. lukas-code commented on Jun 18, 2023

    @lukas-code
    Contributor

    You need -Cdebuginfo=2 to reproduce.

    This is the same as #100612, except it's now failing the assertion in LLVM instead of rustc.

  4. matthiaskrgr commented on Jul 19, 2023

    @matthiaskrgr
    MemberAuthor
    #![feature(repr128)]
    
    #[repr(u128)]
    pub enum NotTrunctable {
        A = 0,
        B([u8; 1024]) = 1,
        C([u8; 4096]) = 0x10000000000000001,
    }
    
    pub fn trunc() {
      let mut a = NotTrunctable::A;
      a = NotTrunctable::B([0; 1024]);
    }
    
    pub fn main() {
      trunc();
    }
    warning: the feature `repr128` is incomplete and may not be safe to use and/or cause compiler crashes
     --> 52F3D9FC05D68B335092D7DEFC92AEAF218938602BBDEF4528FC527AB879E042.rs:1:12
      |
    1 | #![feature(repr128)]
      |            ^^^^^^^
      |
      = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information
      = note: `#[warn(incomplete_features)]` on by default
    
    warning: variable `a` is assigned to, but never used
      --> 52F3D9FC05D68B335092D7DEFC92AEAF218938602BBDEF4528FC527AB879E042.rs:11:11
       |
    11 |   let mut a = NotTrunctable::A;
       |           ^
       |
       = note: consider using `_a` instead
       = note: `#[warn(unused_variables)]` on by default
    
    warning: value assigned to `a` is never read
      --> 52F3D9FC05D68B335092D7DEFC92AEAF218938602BBDEF4528FC527AB879E042.rs:12:3
       |
    12 |   a = NotTrunctable::B([0; 1024]);
       |   ^
       |
       = help: maybe it is overwritten before being read?
       = note: `#[warn(unused_assignments)]` on by default
    
    rustc: /home/matthias/vcs/github/rust_debug_assertions/src/llvm-project/llvm/include/llvm/ADT/APInt.h:1497: uint64_t llvm::APInt::getZExtValue() const: Assertion `getActiveBits() <= 64 && "Too many bits for uint64_t"' failed.
    [1]    1502395 IOT instruction  ~/.rustup/toolchains/local-debug-assertions/bin/rustc  -Cdebuginfo=2
    
  5. istankovic commented on Oct 22, 2023

    @istankovic
    Contributor

    Cannot reproduce this with 1.75.0-nightly.

  6. matthiaskrgr commented on Oct 22, 2023

    @matthiaskrgr
    MemberAuthor

    nightly doesn't have debug assertions, see the corresponding label

  7. istankovic commented on Oct 22, 2023

    @istankovic
    Contributor

    nightly doesn't have debug assertions, see the corresponding label

    Eh, I thought -Cdebuginfo=2 would suffice... oh well.

  8. Enselic commented on Oct 24, 2025

    @Enselic
    Member

    This is the same as #100612, except it's now failing the assertion in LLVM instead of rustc.

    Triage: Let's close this as duplicate then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions