rust-lang / rust-lang/rust-bindgen
GNU integer `_Complex` panics in `build_builtin_ty` (`Non floating-type complex`)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
int _Complex add(int _Complex a, int t);
Bindgen Invocation
$ bindgen input.h -- -std=gnu11
Actual Results
bindgen aborts. Clang accepts GNU integer _Complex (extension, not ISO C). The panic is in build_builtin_ty: CXType_Complex is handled, but the element type match only allows floating kinds.
panicked at bindgen/ir/context.rs:2047:26:
Non floating-type complex? Type(_Complex int, kind: Complex, ...), Type(int, kind: Int, ...)
panic in a function that cannot unwind
thread caused non-unwinding panic. aborting.
The same abort happens for short / unsigned / long _Complex, for a global extern int _Complex G, and for a struct field. _Float16 _Complex no longer panics (that was #2500).
Expected Results
Do not abort. Skip the declaration, emit an opaque blob, or diagnose that integer _Complex is unsupported.
Environment
bindgen: 0.72.1 and 0.73.1 (rust-lang/rust-bindgen 77cbc723)
clang/libclang: Homebrew clang 21.1.8
rustc: 1.97.1
target: aarch64-apple-darwin
OS: macOS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at bindgen/ir/context.rs:2047 and reproduce the issue with the shown input.h and bindgen invocation. Inspect the CXType_Complex handling and its element-type match, then verify that integer _Complex declarations no longer abort and instead receive an explicit supported or diagnostic outcome.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100