Skip to content

Not an item panic for incomplete union #2160

Open

Description

Input C/C++ Header

namespace {
namespace {
template <typename> union a { a b; };
} // namespace
} // namespace

This is nonsensical but results from reduction of a larger real codebase in google/autocxx#779, so is presumably this is the net result of some complex arrangement of templates.

It does compile OK with clang++:

$ cat <<HERE > test.cc
> namespace {
namespace {
template <typename> union a { a b; };
} // namespace
} // namespace
> HERE
$ clang++ -c test.cc 
$ clang++ --version
Debian clang version 13.0.1-+rc1-1~exp4
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Bindgen Invocation

$ git checkout ca78ae9c41998713db0c6fa70cd21089cdb2af2c # current master
$ cargo run -- test.hpp

Actual Results

thread 'main' panicked at 'Not an item: ItemId(3)', src/ir/context.rs:1464:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/65f3f8b220f020e562c5dd848ff7319257a7ba45/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/65f3f8b220f020e562c5dd848ff7319257a7ba45/library/core/src/panicking.rs:107:14
   2: bindgen::ir::context::BindgenContext::resolve_item
             at ./src/ir/context.rs:1464:21
   3: bindgen::ir::context::BindgenContext::resolve_type
             at ./src/ir/context.rs:1428:9
   4: bindgen::ir::ty::Type::layout::{{closure}}
             at ./src/ir/ty.rs:232:21
   5: core::option::Option<T>::or_else
             at /rustc/65f3f8b220f020e562c5dd848ff7319257a7ba45/library/core/src/option.rs:1147:21
   6: bindgen::ir::ty::Type::layout
             at ./src/ir/ty.rs:219:9
   7: bindgen::ir::ty::Type::layout::{{closure}}
             at ./src/ir/ty.rs:232:21
   8: core::option::Option<T>::or_else
             at /rustc/65f3f8b220f020e562c5dd848ff7319257a7ba45/library/core/src/option.rs:1147:21
   9: bindgen::ir::ty::Type::layout
             at ./src/ir/ty.rs:219:9
  10: bindgen::ir::comp::CompInfo::each_known_field_layout
             at ./src/ir/comp.rs:1159:43
  11: bindgen::ir::comp::CompInfo::layout
             at ./src/ir/comp.rs:1115:9
  12: bindgen::ir::ty::Type::layout::{{closure}}
             at ./src/ir/ty.rs:221:43
  13: core::option::Option<T>::or_else
             at /rustc/65f3f8b220f020e562c5dd848ff7319257a7ba45/library/core/src/option.rs:1147:21
  14: bindgen::ir::ty::Type::layout
             at ./src/ir/ty.rs:219:9
  15: bindgen::ir::context::BindgenContext::compute_bitfield_units::{{closure}}
             at ./src/ir/context.rs:976:30
  16: bindgen::ir::context::BindgenContext::with_loaned_item
             at ./src/ir/context.rs:956:22
  17: bindgen::ir::context::BindgenContext::compute_bitfield_units
             at ./src/ir/context.rs:974:13
  18: bindgen::ir::context::BindgenContext::gen
             at ./src/ir/context.rs:1150:9
  19: bindgen::codegen::codegen
             at ./src/codegen/mod.rs:4289:5
  20: bindgen::Bindings::generate
             at ./src/lib.rs:2401:32
  21: bindgen::Builder::generate
             at ./src/lib.rs:1478:9
  22: bindgen::main::{{closure}}
             at ./src/main.rs:52:17
  23: std::panicking::try::do_call
             at /rustc/65f3f8b220f020e562c5dd848ff7319257a7ba45/library/std/src/panicking.rs:406:40
  24: __rust_try
  25: std::panicking::try
             at /rustc/65f3f8b220f020e562c5dd848ff7319257a7ba45/library/std/src/panicking.rs:370:19
  26: std::panic::catch_unwind
             at /rustc/65f3f8b220f020e562c5dd848ff7319257a7ba45/library/std/src/panic.rs:133:14
  27: bindgen::main
             at ./src/main.rs:51:34
  28: core::ops::function::FnOnce::call_once
             at /rustc/65f3f8b220f020e562c5dd848ff7319257a7ba45/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Expected Results

It probably doesn't make much sense to generate any bindings here, but this is currently preventing generation of other things in the same codebase.

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions