Skip to content

Rust enums with discriminators greater than u64::MAX are not encoded properly in debuginfo #111600

Closed
@wesleywiser

Description

@wesleywiser
Member

Rust enums with discriminators greater than u64::MAX are not encoded properly because LLVM lacks the appropriate APIs to do so. As a result, we assert!() in some situations:

// NOTE(eddyb) do *NOT* remove this assert, until
// we pass the full 128-bit value to LLVM, otherwise
// truncation will be silent and remain undetected.
assert_eq!(value as u64 as u128, value);

#![feature(repr128)]

#[repr(u128)]
pub enum Foo {
    Lo,
    Hi = 1 << 64,
    Bar = 18_446_745_000_000_000_123,
}

pub fn foo() -> Option<Foo> {
    None
}

To fix this, we need APIs in LLVM to pass the correct value and have it be encoded in the DWARF.

Split off of #59509

Activity

added
A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
on May 15, 2023
added a commit that references this issue on Jun 16, 2023

Rollup merge of rust-lang#112474 - ldm0:ldm_enum_debuginfo_128_suppor…

3eb8c2a
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-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @wesleywiser

      Issue actions

        Rust enums with discriminators greater than `u64::MAX` are not encoded properly in debuginfo · Issue #111600 · rust-lang/rust