Skip to content

ICE when returning an repr(i8) enum from an extern c function #80556

Closed
@GabeRealB

Description

@GabeRealB

Code

#[repr(i8)]
#[derive(Debug)]
enum Type {
    Type1 = 0,
    Type2 = 1
}

extern "C" fn test() -> Type {
    Type::Type1
}

fn main() {
    println!("{:?}", test())
}

Meta

rustc --version --verbose:

rustc 1.51.0-nightly (e22670468 2020-12-30)
binary: rustc
commit-hash: e2267046859c9ceb932abc983561d53a117089f6
commit-date: 2020-12-30
host: x86_64-pc-windows-msvc
release: 1.51.0-nightly

Error output

Attributes 'zeroext and signext' are incompatible!
i1 ()* @_ZN10playground4test17hdbd7051ebdf54fe6E
in function _ZN10playground4test17hdbd7051ebdf54fe6E
LLVM ERROR: Broken function found, compilation aborted!
error: could not compile `playground`
Backtrace

thread 'rustc' panicked at 'assertion failed: self.arg_ext == ArgExtension::None || self.arg_ext == ext', compiler/rustc_target/src/abi/call/mod.rs:100:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e2267046859c9ceb932abc983561d53a117089f6/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/e2267046859c9ceb932abc983561d53a117089f6/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/e2267046859c9ceb932abc983561d53a117089f6/library/core/src/panicking.rs:50:5
   3: rustc_target::abi::call::ArgAttributes::ext
   4: rustc_target::abi::call::x86_64::compute_abi_info::{{closure}}
   5: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::adjust_for_abi
   6: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::of_instance
   7: rustc_codegen_llvm::mono_item::<impl rustc_codegen_ssa::traits::declare::PreDefineMethods for rustc_codegen_llvm::context::CodegenCx>::predefine_fn
   8: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
   9: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  10: rustc_codegen_llvm::base::compile_codegen_unit
  11: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_interface::passes::QueryContext::enter
  14: rustc_interface::queries::Queries::ongoing_codegen
  15: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  16: rustc_span::with_source_map
  17: rustc_interface::interface::create_compiler_and_run

Metadata

Metadata

Assignees

Labels

A-codegenArea: Code generationC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions