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

Panic in nightly using repr(u128) with constant higher than is representable #77457

Closed
LFalch opened this issue Oct 2, 2020 · 1 comment · Fixed by #77488
Closed

Panic in nightly using repr(u128) with constant higher than is representable #77457

LFalch opened this issue Oct 2, 2020 · 1 comment · Fixed by #77488
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. 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.

Comments

@LFalch
Copy link

LFalch commented Oct 2, 2020

Code

#![feature(repr128, const_int_pow)]
#[repr(u128)]
#[derive(Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq)]
pub enum Prefix {
    Yobi = 1024u128.pow(8),
}

impl Prefix {
    pub fn from_str(s: &str) -> Option<Self> {
        use self::Prefix::*;
        match s {
            "Yi" => Some(Yobi),
            _ => None,
        }
    }
}
fn main() {
    println!("{:?}", Prefix::from_str("Yi"));
}

Meta

Link to playpen: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=c628f84c710d623db24c7458295437c1

rustc --version --verbose:

rustc 1.48.0-nightly (154f1f544 2020-10-02)
binary: rustc
commit-hash: 154f1f544dd68f7b53ff8d9952811e855f4c2d7c
commit-date: 2020-10-02
host: x86_64-unknown-linux-gnu
release: 1.48.0-nightly
LLVM version: 11.0

Error output

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `1208925819614629174706177`', compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs:1703:33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.48.0-nightly (8fe73e80d 2020-10-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: could not compile `playground`

To learn more, run the command again with --verbose.
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/8fe73e80d762bc575040239fc05fb1c612873554/library/std/src/panicking.rs:483
   1: std::panicking::begin_panic_fmt
             at /rustc/8fe73e80d762bc575040239fc05fb1c612873554/library/std/src/panicking.rs:437
   2: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   3: rustc_codegen_llvm::debuginfo::metadata::MemberDescriptionFactory::create_member_descriptions
   4: rustc_codegen_llvm::debuginfo::metadata::RecursiveTypeDescription::finalize
   5: rustc_codegen_llvm::debuginfo::metadata::type_metadata
   6: rustc_codegen_llvm::debuginfo::metadata::type_metadata::{{closure}}
   7: rustc_codegen_llvm::debuginfo::metadata::type_metadata
   8: rustc_codegen_llvm::debuginfo::<impl rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods for rustc_codegen_llvm::context::CodegenCx>::create_function_debug_context::get_function_signature
   9: rustc_codegen_llvm::debuginfo::<impl rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods for rustc_codegen_llvm::context::CodegenCx>::create_function_debug_context
  10: rustc_codegen_ssa::mir::codegen_mir
  11: rustc_codegen_ssa::base::codegen_instance
  12: <rustc_middle::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define
  13: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  14: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  15: rustc_codegen_llvm::base::compile_codegen_unit
  16: rustc_codegen_ssa::base::codegen_crate
  17: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  18: rustc_session::utils::<impl rustc_session::session::Session>::time
  19: rustc_interface::passes::QueryContext::enter
  20: rustc_interface::queries::Queries::ongoing_codegen
  21: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  22: rustc_span::with_source_map
  23: rustc_interface::interface::create_compiler_and_run
  24: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@LFalch LFalch added C-bug Category: This is a bug. 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. labels Oct 2, 2020
@jonas-schievink jonas-schievink added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Oct 2, 2020
@varkor
Copy link
Member

varkor commented Oct 3, 2020

#[repr(u128)] is currently not supported; see #56071. However, that's not obvious at the moment, and I think we should mark repr128 as an incomplete_features. The panic occurs due to:
https://github.com/rust-lang/rust/blob/78ea2e3d70cf97a7e2e1839b582a6db6ae2aa11a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs#L1700-L1703

JohnTitor added a commit to JohnTitor/rust that referenced this issue Oct 12, 2020
… r=jonas-schievink

Mark `repr128` as `incomplete_features`

As mentioned in rust-lang#56071 and noticed in rust-lang#77457, `repr(u128)` and `repr(i128)` do not work properly due to lack of LLVM support. We should thus warn users trying to use the feature that they may encounter ICEs when using it.

Closes rust-lang#77457.
JohnTitor added a commit to JohnTitor/rust that referenced this issue Oct 12, 2020
… r=jonas-schievink

Mark `repr128` as `incomplete_features`

As mentioned in rust-lang#56071 and noticed in rust-lang#77457, `repr(u128)` and `repr(i128)` do not work properly due to lack of LLVM support. We should thus warn users trying to use the feature that they may encounter ICEs when using it.

Closes rust-lang#77457.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Oct 22, 2020
… r=jonas-schievink

Mark `repr128` as `incomplete_features`

As mentioned in rust-lang#56071 and noticed in rust-lang#77457, `repr(u128)` and `repr(i128)` do not work properly due to lack of LLVM support. We should thus warn users trying to use the feature that they may encounter ICEs when using it.

Closes rust-lang#77457.
@bors bors closed this as completed in da3e41e Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants