rust-lang / rust-lang/rust-bindgen
`_Accum` globals and constants panic (`CXType_Accum` fails the var.rs Auto/Unexposed assert)
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
const _Accum K = 7;
extern _Accum G;
Bindgen Invocation
$ bindgen input.h -- -ffixed-point
Actual Results
bindgen aborts while parsing the variable. _Accum is ISO TR 18037 / clang -ffixed-point. libclang reports CXType_Accum. Function parameters of type _Accum already go through the opaque integer fallback (u32; see #3398). Globals and const objects do not: Item::from_ty fails, and ir/var.rs then asserts that the failed type must be CXType_Auto or CXType_Unexposed.
panicked at bindgen/ir/var.rs:312:25:
Couldn't resolve constant type, and it wasn't an nondeductible auto type or unexposed type: Type(const _Accum, kind: Accum, ...)
panic in a function that cannot unwind
thread caused non-unwinding panic. aborting.
extern short _Accum and extern unsigned _Accum abort the same way. A function-only header int take(_Accum a); does not abort.
This is the same assertion text as the old _Atomic crashes (#2882 / #2920), but the type here is CXType_Accum, not _Atomic.
Expected Results
Do not abort. Skip the variable, or use the same opaque integer fallback already used for _Accum parameters.
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
Reproduce the panic with the provided header and bindgen invocation, then start in bindgen/ir/var.rs around the assertion and trace the failed Item::from_ty resolution for CXType_Accum. Compare this path with the existing _Accum handling for function parameters. Done means globals and const objects no longer abort and follow one of the expected outcomes: skipping the variable or using the opaque integer fallback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100