`_Accum` globals and constants panic (`CXType_Accum` fails the var.rs Auto/Unexposed assert)

Open
#3,469 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c, rust

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.

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
Dominant language
Rust
Stars
5.3k
Forks
846
Avg merge
2d 6h
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/rust-bindgen

All issues in rust-lang/rust-bindgen

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.