rust-lang / rust-lang/rust-bindgen

`nullptr_t` bindings name a type that is never defined

Open
#3,437 0 comments 0 reactions 0 assignees View on GitHub

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
#include <stddef.h>

nullptr_t ident(nullptr_t p);
int is_null(nullptr_t p);
Bindgen Invocation
$ bindgen input.h --no-rustfmt-bindings --output bindings.rs -- -std=c23
Actual Results

bindgen exits 0 and emits uses of nullptr_t without defining it:

pub type wchar_t = ::std::os::raw::c_int;
pub type max_align_t = f64;

unsafe extern "C" {
    pub fn ident(p: nullptr_t) -> nullptr_t;
}
unsafe extern "C" {
    pub fn is_null(p: nullptr_t) -> ::std::os::raw::c_int;
}

rustc then fails:

error[E0425]: cannot find type `nullptr_t` in this scope

clang's AST does have the type (BuiltinType 'nullptr_t', plus the stddef.h typedef). Layout is pointer-sized.

Expected Results

Either:

  • emit a Rust alias for nullptr_t (for example *const c_void, which matches the pointer-sized builtin), or
  • skip these declarations instead of generating code that does not compile.
Environment
bindgen release: 0.72.1
clang:           Apple clang 21.0.0 (also reproduced with clang 18 on x86_64-linux)
rustc:           1.97.1
target:          aarch64-apple-darwin

Contributor guide

Open the contributing guide

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.

Research direction

Reproduce the bindgen invocation with input.h and inspect bindings.rs, then trace how clang's BuiltinType nullptr_t and the stddef.h typedef are represented. Done means the generated bindings compile, either by defining a suitable Rust alias or by skipping the affected declarations; add coverage for this C23 input.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.